Failed to handle method call
What happened?
error caught by Zone
PlatformException(error, null cannot be cast to non-null type kotlin.Number, null, java.lang.NullPointerException: null cannot b...
#0 StandardMethodCodec.decodeEnvelope (package:flutter/src/services/message_codecs.dart:648:7)
#1 MethodChannel._invokeMethod (package:flutter/src/services/platform_channel.dart:334:18)
What do you expect?
E/MethodChannel#home_widget(15202): Failed to handle method call E/MethodChannel#home_widget(15202): java.lang.NullPointerException: null cannot be cast to non-null type kotlin.Number E/MethodChannel#home_widget(15202): at es.antonborri.home_widget.HomeWidgetPlugin.onMethodCall(HomeWidgetPlugin.kt:136) E/MethodChannel#home_widget(15202): at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler.onMessage(MethodChannel.java:267) E/MethodChannel#home_widget(15202): at io.flutter.embedding.engine.dart.DartMessenger.invokeHandler(DartMessenger.java:292) E/MethodChannel#home_widget(15202): at io.flutter.embedding.engine.dart.DartMessenger.lambda$dispatchMessageToQueue$0$io-flutter-embedding-engine-dart-DartMessenger(DartMessenger.java:319) E/MethodChannel#home_widget(15202): at io.flutter.embedding.engine.dart.DartMessenger$$ExternalSyntheticLambda0.run(Unknown Source:12) E/MethodChannel#home_widget(15202): at android.os.Handler.handleCallback(Handler.java:958) E/MethodChannel#home_widget(15202): at android.os.Handler.dispatchMessage(Handler.java:99) E/MethodChannel#home_widget(15202): at android.os.Looper.loopOnce(Looper.java:230) E/MethodChannel#home_widget(15202): at android.os.Looper.loop(Looper.java:319) E/MethodChannel#home_widget(15202): at android.app.ActivityThread.main(ActivityThread.java:8919) E/MethodChannel#home_widget(15202): at java.lang.reflect.Method.invoke(Native Method) E/MethodChannel#home_widget(15202): at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:578) E/MethodChannel#home_widget(15202): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1103)
Relevant log output
No response
Execute in a terminal and put output into the code block below
Output of: flutter doctor -v [✓] Flutter (Channel stable, 3.24.4, on macOS 15.0.1 24A348 darwin-arm64, locale en-UZ) • Flutter version 3.24.4 on channel stable at /Users/sunnatillo/src/flutter • Upstream repository https://github.com/flutter/flutter.git • Framework revision 603104015d (8 days ago), 2024-10-24 08:01:25 -0700 • Engine revision db49896cf2 • Dart version 3.5.4 • DevTools version 2.37.3
On which Platform do you experience this issue?
Android
Other information
Crash from plugin received: PlatformException(error, null cannot be cast to non-null type kotlin.Number, null, java.lang.NullPointerException: null cannot be cast to non-null type kotlin.Number I/AppMetrica(15202): at es.antonborri.home_widget.HomeWidgetPlugin.onMethodCall(HomeWidgetPlugin.kt:136) I/AppMetrica(15202): at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler.onMessage(MethodChannel.java:267) I/AppMetrica(15202): at io.flutter.embedding.engine.dart.DartMessenger.invokeHandler(DartMessenger.java:292) I/AppMetrica(15202): at io.flutter.embedding.engine.dart.DartMessenger.lambda$dispatchMessageToQueue$0$io-flutter-embedding-engine-dart-DartMessenger(DartMessenger.java:319) I/AppMetrica(15202): at io.flutter.embedding.engine.dart.DartMessenger$$ExternalSyntheticLambda0.run(Unknown Source:12) I/AppMetrica(15202): at android.os.Handler.handleCallback(Handler.java:958) I/AppMetrica(15202): at android.os.Handler.dispatchMessage(Handler.java:99) I/AppMetrica(15202): at android.os.Looper.loopOnce(Looper.java:230) I/AppMetrica(15202): at android.os.Looper.loop(Looper.java:319) I/AppMetrica(15202): at android.app.ActivityThread.main(ActivityThread.java:8919) I/AppMetrica(15202): at java.lang.reflect.Method.invoke(Native Method) I/AppMetrica(15202): at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:578) I/AppMetrica(15202): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1103)
Are you interested in working on a PR for this?
- [X] I want to work on this
Can you share the code where you register the callback? Seems to me like the function you provide is not static accessible
HomeWidget.initiallyLaunchedFromHomeWidget().then(_launchedFromWidget); HomeWidget.widgetClicked.forEach(_launchedFromWidget); HomeWidget.registerInteractivityCallback(backgroundCallback);
// Called when Doing Background Work initiated from Widget
Future
Will need some more Info where the function is defined. The callback has to be statically accessible. So ideally it lives outside of your class. Also ensure you annotate it correctly.
https://docs.page/abausg/home_widget/features/interactive-widgets#flutter-setup