How to enable Location in Flutter with flutter_webview plugin?

2,647

you have to use flutter_webview_plugin, there is a geolocation property you can enable it.
check this code

 Widget build(BuildContext context) { 
return WebviewScaffold( 
  url: url, 
  withZoom: true, 
  hidden: true, 
  geolocationEnabled: true,
);
} 
Share:
2,647
Toothless
Author by

Toothless

Passionate programmer. Want to learn more and help others. Big Fan of Open Source software. We need to make all free. I have a passion for learning all possible programming languages. But as of now, I know PHP, JavaScript, Python and recently started with Flutter. All self-taught language. Have worked with WordPress and Bootstrap too for fun.

Updated on December 24, 2022

Comments

  • Toothless
    Toothless over 1 year

    I am currently using flutter_webview plugin for a project. In one of the page, I need to get the user location information to calculate the distance. There is JavaScript running on the webpage to get the location.

    Here is my sample code.

    WebView(
      key: _key,
      initialUrl: "https://www.w3schools.com/html/html5_geolocation.asp",
      javascriptMode: JavascriptMode.unrestricted,
      onPageFinished: (_) {
        setState(() {
          _isLoading = false;
        });
      },
    ),
    

    If I open the same page on chrome, it asks for the location permission. I wanted to implement something like that.

    I tried using permissions on AndroidManifest file but could not make it work.

  • vinender singh
    vinender singh almost 2 years
    How to use this in main function?