J'ai utilisé ceci comme référence.
class _LoadingScreenState extends State<LoadingScreen> {
@override
void initState() {
super.initState();
// ---Utilisé ici---
getLocation();
// ------------------
}
void getLocation() async {
Position position = await Geolocator().getCurrentPosition(
desiredAccuracy: LocationAccuracy.low,
);
print(position);
}
E/flutter (14324): This Overlay widget cannot be marked as needing to build because the framework is already in the process of building widgets. A widget can be marked as needing to be built during the build phase only if one of its ancestors is currently building. This exception is allowed because the framework builds parent widgets before children, which means a dirty descendant will always be built. Otherwise, the framework might not visit this widget during this build phase.
void getLocationData() async {
var weatherData =★ Attendre est requis ici ★ WeatherModel().getLocationWeather();
Navigator.push(context, MaterialPageRoute(builder: (context) {
return LocationScreen(
locationWeather: weatherData,
);
}));
}
Tenter de créer un widget lors de la récupération des données signifie que le processus tente de recevoir des données incomplètes (nulles) et la création du widget échoue.