Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix web info #18

Merged
merged 1 commit into from
Dec 18, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 13 additions & 6 deletions lib/sys_info.dart
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@ class SystemInfo {
static const String _kIPhoneOsName = "iOS";
static const String _kMacOsName = "macOS";
static const String _kWindowsOsName = "Windows";
static const String _kWebOsName = "";
static const String _kWebOsVersion = "";

static const String _kUnknownOsVersion = "";
static const String _kIpadModelString = "ipad";
Expand All @@ -36,9 +34,13 @@ class SystemInfo {

final packageInfo = await PackageInfo.fromPlatform();

final osVersion = osInfo.version.length > 100
? osInfo.version.substring(0, 100)
: osInfo.version;

return SystemInfo._(
osName: osInfo.name,
osVersion: osInfo.version,
osVersion: osVersion,
locale: Platform.localeName,
buildNumber: packageInfo.buildNumber,
appVersion: packageInfo.version,
Expand All @@ -47,11 +49,16 @@ class SystemInfo {

/// Returns info (name and version) of the operating system.
static Future<({String name, String version})> _getOsInfo() async {
final deviceInfo = DeviceInfoPlugin();

if (kIsWeb) {
return (name: _kWebOsName, version: _kWebOsVersion);
}
final info = await deviceInfo.webBrowserInfo;

final deviceInfo = DeviceInfoPlugin();
return (
name: info.browserName.name,
version: info.appVersion ?? "",
);
}

if (Platform.isAndroid) {
final info = await deviceInfo.androidInfo;
Expand Down