Enable location in Flutter webview on Android

I have a webapp which uses Google Maps. I deploy the app as-is on the web and I also wrap it in Flutter (using webview_flutter) as an app for ios and android.

Getting the current position in the standalone web app works fine (user needs to opt-in to share location in the browser pop-up) and it also works fine in the ios flutter app. In the iOS app the user gets the same opt-in as he gets in a regular browser. However, when I run the app on Android the positioning does not work.

Why is this, and is there any way around it?

I know about the older flutter_webview_plugin library which has a geolocationEnabled: true option but I’d rather not use that one since it is not actively maintained any more. And since geo location is working for me on iOS I wonder if there is just some Android/Chrome issue I’ve run into.

Alternatively I could implement the location part in native Flutter and just call this from my webview, but that leads to separate code paths for my Flutter version vs my standalone web app so it is not my first choice.

Source: Android Questions

One Reply to “Enable location in Flutter webview on Android”

LEAVE A COMMENT