-
-
Notifications
You must be signed in to change notification settings - Fork 1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Bug]: DeviceInfoPlugin.webBrowserInfo fails locally on Safari #3391
Comments
It's a strange issue, the only property that is a |
@miquelbeltran We are having the same issue also with Chrome sometimes. I don't know why sometimes the Here We tested the following code and this could be a temporary fix for the library. With the following extension extension SafeNavigationGetterExtensions on html.Navigator {
double? safeDeviceMemory() {
try {
return deviceMemory;
} catch (e) {
return 0.0;
}
}
} we can change the @override
Future<BaseDeviceInfo> deviceInfo() {
return Future<WebBrowserInfo>.value(
WebBrowserInfo.fromMap(
{
'appCodeName': _navigator.appCodeName,
'appName': _navigator.appName,
'appVersion': _navigator.appVersion,
'deviceMemory': _navigator.safeDeviceMemory(),
'language': _navigator.language,
'languages': _navigator.languages,
'platform': _navigator.platform,
'product': _navigator.product,
'productSub': _navigator.productSub,
'userAgent': _navigator.userAgent,
'vendor': _navigator.vendor,
'vendorSub': _navigator.vendorSub,
'hardwareConcurrency': _navigator.hardwareConcurrency,
'maxTouchPoints': _navigator.maxTouchPoints,
},
),
); This solution can be used also for fixing other fields with the same problem. Do you think this fix can be integrated in the package? |
Yes, thanks for researching this, feel free to submit a PR with the change |
Platform
Web
Plugin
device_info_plus
Version
11.1.1
Flutter SDK
3.24.5
Steps to reproduce
Write a Flutter app that uses device_info_plus plugin to get web browser info.
Run web server locally on a macOS device:
Open a Flutter app on a Safari browser locally. A
TypeError
is thrown. The error does not occur in a--release
build though.Code Sample
Logs
Flutter Doctor
[✓] Flutter (Channel stable, 3.24.5, on macOS 15.1 24B83 darwin-arm64, locale en-LV) • Flutter version 3.24.5 on channel stable at /Users/sergey/Developer/flutter • Upstream repository https://github.com/flutter/flutter.git • Framework revision dec2ee5c1f (4 weeks ago), 2024-11-13 11:13:06 -0800 • Engine revision a18df97ca5 • Dart version 3.5.4 • DevTools version 2.37.3 [✓] Android toolchain - develop for Android devices (Android SDK version 33.0.1) • Android SDK at /Users/sergey/Library/Android/sdk • Platform android-34, build-tools 33.0.1 • ANDROID_HOME = /Users/sergey/Library/Android/sdk • Java binary at: /Applications/Android Studio.app/Contents/jbr/Contents/Home/bin/java • Java version OpenJDK Runtime Environment (build 17.0.11+0-17.0.11b1207.24-11852314) • All Android licenses accepted.
Checklist before submitting a bug
flutter pub upgrade
flutter clean
The text was updated successfully, but these errors were encountered: