Closed MarcVanDaele90 closed 1 year ago
Can you provide your flutter environment information by running flutter doctor -v.
And if possible, you can paste your code snippet to help me figure out the problem. :)
Thank for looking into this!
output of flutter doctor -v
[✓] Flutter (Channel stable, 2.10.3, on Linux Mint 20.2 5.11.0-43-generic, locale en_US.UTF-8)
• Flutter version 2.10.3 at /home/marc/snap/flutter/common/flutter
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision 7e9793dee1 (3 weeks ago), 2022-03-02 11:23:12 -0600
• Engine revision bd539267b4
• Dart version 2.16.1
• DevTools version 2.9.2
[✓] Android toolchain - develop for Android devices (Android SDK version 31.0.0)
• Android SDK at /home/marc/Android/Sdk
• Platform android-31, build-tools 31.0.0
• Java binary at: /home/marc/android-studio/jre/bin/java
• Java version OpenJDK Runtime Environment (build 11.0.10+0-b96-7249189)
• All Android licenses accepted.
[✓] Chrome - develop for the web
• Chrome at google-chrome
[✓] Linux toolchain - develop for Linux desktop
• clang version 6.0.0-1ubuntu2 (tags/RELEASE_600/final)
• cmake version 3.10.2
• ninja version 1.8.2
• pkg-config version 0.29.1
[✓] Android Studio (version 2020.3)
• Android Studio at /home/marc/android-studio
• Flutter plugin version 59.0.2
• Dart plugin version 203.8292
• Java version OpenJDK Runtime Environment (build 11.0.10+0-b96-7249189)
[✓] VS Code (version 1.65.1)
• VS Code at /usr/share/code
• Flutter extension can be installed from:
🔨 https://marketplace.visualstudio.com/items?itemName=Dart-Code.flutter
[✓] Connected device (2 available)
• Linux (desktop) • linux • linux-x64 • Linux Mint 20.2 5.11.0-43-generic
• Chrome (web) • chrome • web-javascript • Google Chrome 99.0.4844.51
[✓] HTTP Host Availability
• All required HTTP hosts are available
• No issues found!
I just use a default/initial Flutter application where I add a call to test() inside _MyHomePageState.build()
where test() is
void test() async {
// Get client information
print(">>>test");
ClientInformation info = await ClientInformation.fetch();
print(info.deviceId); // EA625164-4XXX-XXXX-XXXXXXXXXXXX
print(info.osName); // iOS
print("<<<test");
}
The stacktrace is
Error: PlatformException(error, type 'Null' is not a 'bool' in boolean expression, null, null)
at Object.throw_ [as throw] (http://localhost:37601/dart_sdk.js:5067:11)
at StandardMethodCodec.decodeEnvelope (http://localhost:37601/packages/flutter/src/services/restoration.dart.lib.js:2359:19)
at MethodChannel._invokeMethod (http://localhost:37601/packages/flutter/src/services/restoration.dart.lib.js:1562:47)
at _invokeMethod.next (<anonymous>)
at http://localhost:37601/dart_sdk.js:40571:33
at _RootZone.runUnary (http://localhost:37601/dart_sdk.js:40441:59)
at _FutureListener.thenAwait.handleValue (http://localhost:37601/dart_sdk.js:35363:29)
at handleValueCallback (http://localhost:37601/dart_sdk.js:35931:49)
at Function._propagateToListeners (http://localhost:37601/dart_sdk.js:35969:17)
at _Future.new.[_completeWithValue] (http://localhost:37601/dart_sdk.js:35817:23)
at async._AsyncCallbackEntry.new.callback (http://localhost:37601/dart_sdk.js:35838:35)
at Object._microtaskLoop (http://localhost:37601/dart_sdk.js:40708:13)
at _startMicrotaskLoop (http://localhost:37601/dart_sdk.js:40714:13)
at http://localhost:37601/dart_sdk.js:36191:9
I can't reproduce it. ;(
Could you try to run the package's example project? And tell me the result?
It's a pity that you can't reproduce the issue.
The example project prints (I've added a catch to the on PlatformException to print the actual exception) "Failed to get client information PlatformException(error, Failed assertion: boolean expression must not be null, null, null)"
So apparently, it is somehow related to my environment
I was able to fix it: in _Software _getOS you use '!osName' construct. I've replaced it with 'osName==null' and now it seems to work fine. When I code something like this (negation operator on an object), I get an error in my Dart Analysis tab of Android Studio.
see also https://dart.dev/tools/diagnostic-messages#non_bool_negation_expression
same issue
I am really just a newbie when it comes to Dart, but I fixed the problem locally with this change, seems to work in Linux and Flutter-Web. https://github.com/Kent1011/client_information/pull/8
(I have only tested it on Linux, that's all I have access to this week)
When running
ClientInformation.fetch()
in flutter web (on Linux) I getPlease let me know if I can help in debugging somehow.