File tree Expand file tree Collapse file tree 1 file changed +14
-1
lines changed
packages/device_info_plus/device_info_plus/lib/src Expand file tree Collapse file tree 1 file changed +14
-1
lines changed Original file line number Diff line number Diff line change @@ -29,7 +29,7 @@ class DeviceInfoPlusWebPlugin extends DeviceInfoPlatform {
2929 'appCodeName' : _navigator.appCodeName,
3030 'appName' : _navigator.appName,
3131 'appVersion' : _navigator.appVersion,
32- 'deviceMemory' : _navigator.deviceMemory ,
32+ 'deviceMemory' : _navigator.safeDeviceMemory ,
3333 'language' : _navigator.language,
3434 'languages' : _navigator.languages.toDart,
3535 'platform' : _navigator.platform,
@@ -45,3 +45,16 @@ class DeviceInfoPlusWebPlugin extends DeviceInfoPlatform {
4545 );
4646 }
4747}
48+
49+ /// Some Navigator properties are not fully supported in all browsers.
50+ /// However, package:web does not provide a safe way to access these properties,
51+ /// and assumes they are always not null.
52+ ///
53+ /// This extension provides a safe way to access these properties.
54+ ///
55+ /// See: https://github.com/dart-lang/web/issues/326
56+ /// https://github.com/fluttercommunity/plus_plugins/issues/3391
57+ extension SafeNavigationGetterExtensions on html.Navigator {
58+ @JS ('deviceMemory' )
59+ external double ? get safeDeviceMemory;
60+ }
You can’t perform that action at this time.
0 commit comments