-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Unhandled Exception: Null check operator used on a null value #276
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
Comments
I have this issue too. |
I can confirm that the issue is present in both 1.0.0 and 1.0.1; this is likely a regression introduced by null-safety. |
I just tried this package and I get the same error (v1.0.2). Error occurs in platform_channel.dart (line 358): final Map<dynamic, dynamic>? result = await invokeMethod<Map<dynamic, dynamic>?>(method, arguments); |
PRs with the fix are welcome :) |
This comment has been minimized.
This comment has been minimized.
So my problem was in package_info_plus. I solved it by moving the code that calls package info plus to after WidgetsFlutterBinding.ensureInitialized(); in my main.dart file. |
Yes, I think this is a general limitation of all platform plugins. Just this week there was another dev reporting the same, they were calling to the plugin before the |
Maybe the documentation could be updated to say that instead of doing it after runapp, you could also put your code after a call to WidgetsFlutterBinding.ensureInitialized(). |
@miquelbeltran I think this issue can be closed, as the readme of the package already states that
|
Yes, thanks @fabiancrx ! |
System info
Issue occurs on: iOS / Android / both
Plugin name:Android Emulator
Plugin version:android_alarm_manager_plus: ^0.6.0
Flutter doctor output:
[✓] Flutter (Channel stable, 2.2.1, on Mac OS X 10.15.7 19H1217 darwin-x64, locale en-IN)
• Flutter version 2.2.1 at /Users/sudheerpalaparambil/Flutter/flutter
• Framework revision 02c026b03c (8 days ago), 2021-05-27 12:24:44 -0700
• Engine revision 0fdb562ac8
• Dart version 2.13.1
[!] Android toolchain - develop for Android devices (Android SDK version 29.0.2)
• Android SDK at /Users/sudheerpalaparambil/Library/Android/sdk
• Platform android-30, build-tools 29.0.2
• ANDROID_HOME = /Users/sudheerpalaparambil/Library/Android/sdk
• Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
• Java version OpenJDK Runtime Environment (build 11.0.8+10-b944.6916264)
✗ Android license status unknown.
Run
flutter doctor --android-licenses
to accept the SDK licenses.See https://flutter.dev/docs/get-started/install/macos#android-setup for more details.
[!] Xcode - develop for iOS and macOS
• Xcode at /Applications/Xcode.app/Contents/Developer
• Xcode 11.3, Build version 11C29
✗ Xcode 11.3.0 out of date (12.0.1 is recommended).
Download the latest version or update via the Mac App Store.
✗ CocoaPods installed but not working.
You appear to have CocoaPods installed but it is not working.
This can happen if the version of Ruby that CocoaPods was installed with is different from the one being used to invoke it.
This can usually be fixed by re-installing CocoaPods.
To re-install see https://guides.cocoapods.org/using/getting-started.html#installation for instructions.
[✓] Chrome - develop for the web
• Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
[✓] Android Studio (version 4.2)
• Android Studio at /Applications/Android Studio.app/Contents
• Flutter plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/9212-flutter
• Dart plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/6351-dart
• Java version OpenJDK Runtime Environment (build 11.0.8+10-b944.6916264)
[✓] VS Code (version 1.56.2)
• VS Code at /Applications/Visual Studio Code.app/Contents
• Flutter extension version 3.23.0
[✓] Connected device (2 available)
• Android SDK built for x86 (mobile) • emulator-5554 • android-x86 • Android 5.1.1 (API 22) (emulator)
• Chrome (web) • chrome • web-javascript • Google Chrome 91.0.4472.77
! Doctor found issues in 2 categories.
Steps to Reproduce
import 'package:android_alarm_manager_plus/android_alarm_manager_plus.dart';
void printHello() {
final DateTime now = DateTime.now();
final int isolateId = Isolate.current.hashCode;
print("[$now] Hello, world! isolate=${isolateId} function='$printHello'");
}
main() async {
final int helloAlarmID = 0;
await AndroidAlarmManager.initialize(); /* This line is giving the following error. */
runApp(MyApp());
await AndroidAlarmManager.periodic(const Duration(minutes: 1), helloAlarmID, printHello);
}
Installing build/app/outputs/flutter-apk/app.apk...
D/FlutterLocationService( 3268): Creating service.
D/FlutterLocationService( 3268): Binding to location service.
Debug service listening on ws://127.0.0.1:62062/NVE5ZeeclXo=/ws
Syncing files to device Android SDK built for x86...
E/flutter ( 3268): [ERROR:flutter/lib/ui/ui_dart_state.cc(199)] Unhandled Exception: Null check operator used on a null value
E/flutter ( 3268): #0 MethodChannel.binaryMessenger (package:flutter/src/services/platform_channel.dart:142:86)
E/flutter ( 3268): #1 MethodChannel._invokeMethod (package:flutter/src/services/platform_channel.dart:148:36)
E/flutter ( 3268): #2 MethodChannel.invokeMethod (package:flutter/src/services/platform_channel.dart:331:12)
E/flutter ( 3268): #3 AndroidAlarmManager.initialize (package:android_alarm_manager_plus/android_alarm_manager_plus.dart:96:30)
E/flutter ( 3268): #4 main (package:poorna_tbs_app/Main.dart:13:41)
E/flutter ( 3268): #5 _runMainZoned.. (dart:ui/hooks.dart:142:25)
E/flutter ( 3268): #6 _rootRun (dart:async/zone.dart:1354:13)
E/flutter ( 3268): #7 _CustomZone.run (dart:async/zone.dart:1258:19)
E/flutter ( 3268): #8 _runZoned (dart:async/zone.dart:1789:10)
E/flutter ( 3268): #9 runZonedGuarded (dart:async/zone.dart:1777:12)
E/flutter ( 3268): #10 _runMainZoned. (dart:ui/hooks.dart:138:5)
E/flutter ( 3268): #11 _delayEntrypointInvocation. (dart:isolate-patch/isolate_patch.dart:283:19)
E/flutter ( 3268): #12 _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:184:12)
E/flutter ( 3268):
The text was updated successfully, but these errors were encountered: