flutterlocation
flutterlocation copied to clipboard
get location on background
My idea is When App receives the background firebase notification, App gets the current location.
My code is

But I am getting an error.
E/MethodChannel#lyokone/location(27361): Failed to handle method call E/MethodChannel#lyokone/location(27361): java.lang.NullPointerException: Attempt to write to field 'io.flutter.plugin.common.MethodChannel$Result com.lyokone.location.FlutterLocation.getLocationResult' on a null object reference E/MethodChannel#lyokone/location(27361): at com.lyokone.location.MethodCallHandlerImpl.onGetLocation(MethodCallHandlerImpl.java:117) E/MethodChannel#lyokone/location(27361): at com.lyokone.location.MethodCallHandlerImpl.onMethodCall(MethodCallHandlerImpl.java:43) E/MethodChannel#lyokone/location(27361): at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler.onMessage(MethodChannel.java:262) E/MethodChannel#lyokone/location(27361): at io.flutter.embedding.engine.dart.DartMessenger.invokeHandler(DartMessenger.java:296) E/MethodChannel#lyokone/location(27361): at io.flutter.embedding.engine.dart.DartMessenger.lambda$dispatchMessageToQueue$0$DartMessenger(DartMessenger.java:320) E/MethodChannel#lyokone/location(27361): at io.flutter.embedding.engine.dart.-$$Lambda$DartMessenger$TsixYUB5E6FpKhMtCSQVHKE89gQ.run(Unknown Source:12) E/MethodChannel#lyokone/location(27361): at android.os.Handler.handleCallback(Handler.java:883) E/MethodChannel#lyokone/location(27361): at android.os.Handler.dispatchMessage(Handler.java:100) E/MethodChannel#lyokone/location(27361): at android.os.Looper.loop(Looper.java:237) E/MethodChannel#lyokone/location(27361): at android.app.ActivityThread.main(ActivityThread.java:7971) E/MethodChannel#lyokone/location(27361): at java.lang.reflect.Method.invoke(Native Method) E/MethodChannel#lyokone/location(27361): at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493) E/MethodChannel#lyokone/location(27361): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1076) I/flutter (27361): FlutterFire Messaging: An error occurred in your background messaging handler: I/flutter (27361): PlatformException(error, Attempt to write to field 'io.flutter.plugin.common.MethodChannel$Result com.lyokone.location.FlutterLocation.getLocationResult' on a null object reference, null, java.lang.NullPointerException: Attempt to write to field 'io.flutter.plugin.common.MethodChannel$Result com.lyokone.location.FlutterLocation.getLocationResult' on a null object reference I/flutter (27361): at com.lyokone.location.MethodCallHandlerImpl.onGetLocation(MethodCallHandlerImpl.java:117) I/flutter (27361): at com.lyokone.location.MethodCallHandlerImpl.onMethodCall(MethodCallHandlerImpl.java:43) I/flutter (27361): at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler.onMessage(MethodChannel.java:262) I/flutter (27361): at io.flutter.embedding.engine.dart.DartMessenger.invokeHandler(DartMessenger.java:296) I/flutter (27361): at io.flutter.embedding.engine.dart.DartMessenger.lambda$dispatchMessageToQueue$0$DartMessenger(DartMessenger.java:320) I/flutter (27361): at io.flutter.embedding.engine.dart.-$$Lambda$DartMessenger$TsixYUB5E6FpKhMtCSQVHKE89gQ.run(Unknown Source:12) I/flutter (27361): at android.os.Handler.handleCallback(
Do you have an idea to fix this? Thank you.
Getting the same error and location.onLocationChanged is not getting called
Any solution for this issue yet?