Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

177
Views
I want to recieve geo location using webview of site but in flutter dart app using javascript

JavaScript Code:

var x = document.getElementById("x");

    document.getElementById('button').onclick = function() 
    {
        function showPosition(position) 
        {
            console.log("in showPosition");
            x.innerHTML = "Latitude: " + position.coords.latitude +
                "<br>Longitude: " + position.coords.longitude;
        }
        alert("button was clicked");
        console.log("sdfghj");
        if (navigator.geolocation) 
        {

            navigator.geolocation.getCurrentPosition(showPosition);
            console.log("in if ");



        }else 
        {
            x.innerHTML = "Geolocation is not supported by this browser.";
            console.log("in else ");

        }

    }

But the permission request popup never opens. Flutter Code:

import 'package:flutter/material.dart';
import 'package:webview_flutter/webview_flutter.dart';

class WebViewStack extends StatefulWidget {
  const WebViewStack({Key? key}) : super(key: key);

  @override
  State<WebViewStack> createState() => _WebViewStackState();
}


void main() {
  runApp(
    const MaterialApp(
      home: WebViewStack(),
    ),
  );
}

class _WebViewStackState extends State<WebViewStack> {
  var loadingPercentage = 0;

  @override
  Widget build(BuildContext context) {
    return Stack(
      children: [
        WebView(

          javascriptMode: JavascriptMode.unrestricted,
          initialUrl: 'example.com',
        ),
       
      ],
    );
  }
}

But on web, it's working Fine. What is the correct way to access a user's location from within a WebView?

I am working on a project that needs to get user's current location using HTML 5 geolocation. But I need to know why WebView is not showing my current location. What I've to do to show the map and current location in WebView??

about 4 years ago · Santiago Gelvez
1 answers
Answer question

0

If your question is about missing permissions, you should use a plugin like Permission Handler - https://pub.dev/packages/permission_handler Read through the Readme and you are done. :)

about 4 years ago · Santiago Gelvez Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!