I'm working on a Flutter app which fetches the user's current location, but while the location is being fetched, it shows this ugly red error screen (which disappears once the location is fetched).
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 initState()
:
void _setCurrentLocation() {
Geolocator().getCurrentPosition().then((currLoc) {
setState(() {
currentLocation = currLoc;
});
});
}
The entire source file can also be found here on GitHub.
Thanks in advance!
CircularProgressIndicator()
is displayed infinitely. – Daughterinlaw