title: Flutter: Unhandled Exception: User denied permissions to access the device's location
body: <p>i am trying to get user current location in flutter but its showing map, but not pointing my current location. I have added all required permissions in AndriodManifest file.</p>
  <p>here is snap</p>
  <p><a href="https://i.stack.imgur.com/WrX71.png" rel="noreferrer"><img src="https://i.stack.imgur.com/WrX71.png" alt="enter image description here" /></a></p>
  <p>here are the logs</p>
  <pre><code>I/Google Maps Android API(24140): Google Play services package version: 201817022
  E/GoogleMapController(24140): Cannot enable MyLocation layer as location permissions are not granted
  D/HostConnection(24140): HostConnection::get() New Host Connection established 0xefab0ec0, tid 25110
  E/flutter (24140): [ERROR:flutter/lib/ui/ui_dart_state.cc(199)] Unhandled Exception: User denied permissions to access the device's location.
  E/flutter (24140): #0      MethodChannelGeolocator._handlePlatformException
  package:geolocator_platform_interface/…/implementations/method_channel_geolocator.dart:242
  E/flutter (24140): #1      MethodChannelGeolocator.getCurrentPosition
  package:geolocator_platform_interface/…/implementations/method_channel_geolocator.dart:124
  E/flutter (24140): &lt;asynchronous suspension&gt;
  E/flutter (24140): #2      _locationState.locatepostion
  package:map_app/abc.dart:26
  E/flutter (24140): &lt;asynchronous suspension&gt;
  W/System  (24140): A resource failed to call release.
  </code></pre>
  <p>code</p>
  <pre><code>  Completer&lt;GoogleMapController&gt; _controllerGoogleMap=Completer();
    late GoogleMapController newGoogleMapController;
    double mapbottompadding=0;
  
    GlobalKey&lt;ScaffoldState&gt; scaffoldkey=new GlobalKey&lt;ScaffoldState&gt;();
    late Position currentpositon;
    var geolocator=Geolocator();
  
    void locatepostion() async{
      Position position=await Geolocator.getCurrentPosition(desiredAccuracy: LocationAccuracy.high);
      currentpositon=position;  // this is line 26, it is point before await
  
      LatLng latLngPosition=LatLng(position.latitude,position.longitude);
  
      CameraPosition cameraPosition=new CameraPosition(target: latLngPosition,zoom: 14);
      newGoogleMapController.animateCamera(CameraUpdate.newCameraPosition(cameraPosition));
    }
  
    static final CameraPosition googlepostion=CameraPosition(target: LatLng(37.4249,-122.0657));
  
    @override
    Widget build(BuildContext context) {
      return Scaffold(
        body: Stack(children: [
          GoogleMap(
            padding: EdgeInsets.only(bottom: mapbottompadding),
            mapType: MapType.normal,
            myLocationButtonEnabled: true,
            myLocationEnabled: true,
            zoomControlsEnabled: true,
            zoomGesturesEnabled: true,
             initialCameraPosition: googlepostion,
            onMapCreated: (GoogleMapController controller){
                _controllerGoogleMap.complete(controller);
                newGoogleMapController=controller;
                setState(() {
                  mapbottompadding=300.0;
                });         
                locatepostion();
           
  
  </code></pre>
  <p>and here is my output</p>
  <p><a href="https://i.stack.imgur.com/HGN5e.png" rel="noreferrer"><img src="https://i.stack.imgur.com/HGN5e.png" alt="enter image description here" /></a></p>
  <p><strong>-------Update</strong></p>
  <p>it's working perfectly on andriod phone, but not working on emulator.
  and i want to ask how can i resize the map, i am using width and height but not working.</p>