title: Flutter - Google Maps doesn´t wait to Location
body: <p>I´m trying to show a map with current location. For do this i used <a href="https://pub.dev/packages/location#-readme-tab-" rel="nofollow noreferrer"><strong>Location</strong></a> and <a href="https://pub.dev/packages/google_maps_flutter" rel="nofollow noreferrer"><strong>Google Map</strong></a> plugins (last version).</p>
  
  <p>I have a code similar to:</p>
  
  <pre><code>var lng, lat;
  
            @override
            initState() {
              super.initState();
              loading = true;
              getLocation();
            }
  
                Future getLocation() async {
                      final location = Location();
                      var currentLocation = await location.getLocation();
                      setState(() {
                        lat = currentLocation.latitude;
                        lng = currentLocation.longitude;
                        loading=false;
                      });
                    }
  
               loading==false ? GoogleMap(
                   mapType: MapType.hybrid,
                   myLocationButtonEnabled: true,
                   myLocationEnabled: true,
                   initialCameraPosition: CameraPosition(
                        target: LatLng(lat, lng),
                        zoom: 15.0,
                              )):null,
  </code></pre>
  
  <p>When we go the view with map a error appear around 1s (then view load properly) with this error in the console</p>
  
  <blockquote>
    <p>I/flutter (15567): ══╡ EXCEPTION CAUGHT BY WIDGETS LIBRARY
    ╞═══════════════════════════════════════════════════════════ I/flutter
    (15567): The following assertion was thrown building
    HomePageScreen(dirty, dependencies: I/flutter (15567):
    [_LocalizationsScope-[GlobalKey#78c30], MediaQuery], state:
    _HomePageScreen#9c9d2): I/flutter (15567): 'package:google_maps_flutter/src/location.dart': Failed assertion:
    line 17 pos 16: 'latitude != I/flutter (15567): null': is not true.</p>
  </blockquote>
  
  <p>I debug it and the error is relative simple: The <em>Location</em> plugin load latitude and longitude slow , <em>Google Maps</em> plugin load more fast. So we have a error.</p>
  
  <p>The question is: How can i force Google map to wait location and longitude from Location plugin?</p>