null error due to delay in api response
String text; fetchData() async { //... text = weatherData.weather[0].main ?? 'Waiting api response...'; //... } // in your build method @override Widget build(BuildContext context) { return Scaffold( body: Container( child: Text(text), //this will render "Waiting api response" first, and when the api result arrive, it will change ), ); }