Skip to content
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

Failed to handle method call #308

Open
1 task done
SunnatilloShavkatov opened this issue Nov 1, 2024 · 3 comments
Open
1 task done

Failed to handle method call #308

SunnatilloShavkatov opened this issue Nov 1, 2024 · 3 comments
Labels
bug Something isn't working

Comments

@SunnatilloShavkatov
Copy link

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?

  • I want to work on this
@SunnatilloShavkatov SunnatilloShavkatov added the bug Something isn't working label Nov 1, 2024
@ABausG
Copy link
Owner

ABausG commented Nov 1, 2024

Can you share the code where you register the callback? Seems to me like the function you provide is not static accessible

@SunnatilloShavkatov
Copy link
Author

HomeWidget.initiallyLaunchedFromHomeWidget().then(_launchedFromWidget);
HomeWidget.widgetClicked.forEach(_launchedFromWidget);
HomeWidget.registerInteractivityCallback(backgroundCallback);

// Called when Doing Background Work initiated from Widget
Future backgroundCallback(Uri? uri) async {
_launchedFromWidget(uri);
}

@ABausG
Copy link
Owner

ABausG commented Nov 1, 2024

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants