Skip to content

Commit

Permalink
Merge pull request #18 from GabrielRozendo/fix_web_info
Browse files Browse the repository at this point in the history
Fix web info
  • Loading branch information
cristipufu authored Dec 18, 2024
2 parents c2ef51e + ba8e2dc commit 8079602
Showing 1 changed file with 13 additions and 6 deletions.
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

0 comments on commit 8079602

Please sign in to comment.