File tree Expand file tree Collapse file tree 1 file changed +12
-3
lines changed
packages/device_info_plus/device_info_plus/lib/src Expand file tree Collapse file tree 1 file changed +12
-3
lines changed Original file line number Diff line number Diff line change @@ -17,8 +17,7 @@ class DeviceInfoPlusWebPlugin extends DeviceInfoPlatform {
1717 /// Factory method that initializes the DeviceInfoPlus plugin platform
1818 /// with an instance of the plugin for the web.
1919 static void registerWith (Registrar registrar) {
20- DeviceInfoPlatform .instance =
21- DeviceInfoPlusWebPlugin (html.window.navigator);
20+ DeviceInfoPlatform .instance = DeviceInfoPlusWebPlugin (html.window.navigator);
2221 }
2322
2423 @override
@@ -29,7 +28,7 @@ class DeviceInfoPlusWebPlugin extends DeviceInfoPlatform {
2928 'appCodeName' : _navigator.appCodeName,
3029 'appName' : _navigator.appName,
3130 'appVersion' : _navigator.appVersion,
32- 'deviceMemory' : _navigator.deviceMemory ,
31+ 'deviceMemory' : _navigator.safeDeviceMemory () ,
3332 'language' : _navigator.language,
3433 'languages' : _navigator.languages.toDart,
3534 'platform' : _navigator.platform,
@@ -45,3 +44,13 @@ class DeviceInfoPlusWebPlugin extends DeviceInfoPlatform {
4544 );
4645 }
4746}
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+ }
You can’t perform that action at this time.
0 commit comments