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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unhandled Exception: MissingPluginException(No implementation found for method getCurrentPosition on channel flutter.baseflow.com/geolocator) #1096

Closed
dukenebur opened this issue Jun 29, 2022 · 5 comments

Comments

@dukenebur
Copy link

dukenebur commented Jun 29, 2022

馃悰 Bug Report

Hi, hope you are doing well.

I am having this error:

Unhandled Exception: MissingPluginException(No implementation found for method getCurrentPosition on channel flutter.baseflow.com/geolocator)

Dart SDK version is 2.13.1
geolocator: 8.0.5

Could you help me?

Kind Regards

@ricardoboss
Copy link

I'm having the same issue on web, but only in production builds. When debugging, it works fine.

@dehypnosis
Copy link

In my case it was due to https://pub.dev/packages/permission_handler library which throw same error message with above one when access to Permission.locationWhenInUse.status on web platform.

@mvanbeusekom
Copy link
Member

Hi @dukenebur,

This error probably occurs while trying to call getCurrentPosition() from the background. If so make sure to register the platform implementations. Something like this on Flutter 2.11+:

void callbackDispatcher() {
  Workmanager().executeTask(task, inputData) async {
    DartPluginRegistrant.ensureInitialized();
    
    // TODO: Put the rest off the code here...
  }
}

or if you are on older Flutter version use:

void callbackDispatcher() {
  Workmanager().executeTask(task, inputData) async {
    if (defaultTargetPlatform == TargetPlatform.android) {
      GeolocatorAndroid.registerWith();
    } else if (defaultTargetPlatform == TargetPlatform.iOS) {
      GeolocatorApple.registerWith();
    }
    
    // TODO: Put the rest off the code here...
  }
}

A more detailed explanation can be found in this comment.

@ricardoboss
Copy link

In their use case, it's "probably" because they are accessing the location while in background. In my case, that app is in foreground, so this doesn't apply to my case. Can you reopen @mvanbeusekom?

@mvanbeusekom
Copy link
Member

Hi @ricardoboss,

It would be better if you'd create a new issue describing the behavior including:

  • Version of the plugin used.
  • Output of the flutter doctor -v command.
  • A copy (preferably stack trace) of the exact exception that occurs.
  • Platform the issue occurs (in this case "web", but please provide information about browsers used).
  • Preferably a reproduction example.

Just a long shot, in the past there were similar issues occurring only on web and only in profile/ release builds, maybe this is related, you could take a look this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants