@@ -17,8 +17,7 @@ class DeviceInfoPlusWebPlugin extends DeviceInfoPlatform {
17
17
/// Factory method that initializes the DeviceInfoPlus plugin platform
18
18
/// with an instance of the plugin for the web.
19
19
static void registerWith (Registrar registrar) {
20
- DeviceInfoPlatform .instance =
21
- DeviceInfoPlusWebPlugin (html.window.navigator);
20
+ DeviceInfoPlatform .instance = DeviceInfoPlusWebPlugin (html.window.navigator);
22
21
}
23
22
24
23
@override
@@ -29,7 +28,7 @@ class DeviceInfoPlusWebPlugin extends DeviceInfoPlatform {
29
28
'appCodeName' : _navigator.appCodeName,
30
29
'appName' : _navigator.appName,
31
30
'appVersion' : _navigator.appVersion,
32
- 'deviceMemory' : _navigator.deviceMemory ,
31
+ 'deviceMemory' : _navigator.safeDeviceMemory () ,
33
32
'language' : _navigator.language,
34
33
'languages' : _navigator.languages.toDart,
35
34
'platform' : _navigator.platform,
@@ -45,3 +44,13 @@ class DeviceInfoPlusWebPlugin extends DeviceInfoPlatform {
45
44
);
46
45
}
47
46
}
47
+
48
+ extension SafeNavigationGetterExtensions on html.Navigator {
49
+ double ? safeDeviceMemory () {
50
+ try {
51
+ return deviceMemory;
52
+ } catch (e) {
53
+ return 0.0 ;
54
+ }
55
+ }
56
+ }
0 commit comments