Flutter WebView Location

Viewed 570

I am creating a WebView of this website https://nearxt.com/ which asks for location when opened but when i use this link to create a webview in flutter then it can not take location i have also defined location in the application but webview cant recieve location

 SafeArea(
    child: WebView(
     javascriptMode: JavascriptMode.unrestricted,
      initialUrl: flutterUrl,
      onWebViewCreated: (WebViewController webViewController) {
        _controller = webViewController;
      },
    ),
  ),
2 Answers

This is unsupported in flutter. Even if you try to ask for location access using permission handler the app will deny it and still if you manually give the location permission to the app from your phone it still won't catch the real time location. Suggestion is to use plain old java for it you can find a lot of help around the internet about webview in java with location access it works perfect.

Use flutter_inappwebview to get users location

InAppWebView(
  initialUrlRequest:
      URLRequest(url: Uri.parse('your link here')),
  androidOnGeolocationPermissionsShowPrompt:
      (InAppWebViewController controller, String origin) async {
    return GeolocationPermissionShowPromptResponse(
      origin: origin,
      allow: true,
      retain: true
    );
  },
)
Related