title: How to display a loading spinner while getting the current location in Flutter?
body: <p>I'm working on a Flutter app which fetches the user's current location, but while the location is being fetched, it shows this <a href="https://i.stack.imgur.com/RPgHW.png" rel="noreferrer">ugly red error screen</a> (which disappears once the location is fetched).</p>
  
  <p>Instead of this, I'd like to display a loading spinner or splash screen. I've narrowed the problem down to this method that is called during <code>initState()</code>:</p>
  
  <pre><code>void _setCurrentLocation() {
    Geolocator().getCurrentPosition().then((currLoc) {
      setState(() {
        currentLocation = currLoc;
      });
    });
  }
  </code></pre>
  
  <p>The entire source file can also be found <a href="https://github.com/fliverdev/rider/blob/master/lib/pages/map_view_page.dart" rel="noreferrer">here on GitHub</a>.</p>
  
  <p>Thanks in advance!</p>