Skip to content

Commit 8079602

Browse files
authored
Merge pull request #18 from GabrielRozendo/fix_web_info
Fix web info
2 parents c2ef51e + ba8e2dc commit 8079602

File tree

1 file changed

+13
-6
lines changed

1 file changed

+13
-6
lines changed

lib/sys_info.dart

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,6 @@ class SystemInfo {
2424
static const String _kIPhoneOsName = "iOS";
2525
static const String _kMacOsName = "macOS";
2626
static const String _kWindowsOsName = "Windows";
27-
static const String _kWebOsName = "";
28-
static const String _kWebOsVersion = "";
2927

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

3735
final packageInfo = await PackageInfo.fromPlatform();
3836

37+
final osVersion = osInfo.version.length > 100
38+
? osInfo.version.substring(0, 100)
39+
: osInfo.version;
40+
3941
return SystemInfo._(
4042
osName: osInfo.name,
41-
osVersion: osInfo.version,
43+
osVersion: osVersion,
4244
locale: Platform.localeName,
4345
buildNumber: packageInfo.buildNumber,
4446
appVersion: packageInfo.version,
@@ -47,11 +49,16 @@ class SystemInfo {
4749

4850
/// Returns info (name and version) of the operating system.
4951
static Future<({String name, String version})> _getOsInfo() async {
52+
final deviceInfo = DeviceInfoPlugin();
53+
5054
if (kIsWeb) {
51-
return (name: _kWebOsName, version: _kWebOsVersion);
52-
}
55+
final info = await deviceInfo.webBrowserInfo;
5356

54-
final deviceInfo = DeviceInfoPlugin();
57+
return (
58+
name: info.browserName.name,
59+
version: info.appVersion ?? "",
60+
);
61+
}
5562

5663
if (Platform.isAndroid) {
5764
final info = await deviceInfo.androidInfo;

0 commit comments

Comments
 (0)