I am using RefreshIndicator
to refresh data from the internet, but when I pulled down from the top, the refresh icon didn't disappear, also an error occured:
════════ Exception caught by material library ══════════════════════════════════
The following assertion was thrown when calling onRefresh:
The onRefresh callback returned null.
The RefreshIndicator onRefresh callback must return a Future.
════════════════════════════════════════════════════════════════════════════════
Here's my code where the method to get data is declared:
Future<void> getApiData() async {
return fetchWorldData();
}
Future<Map<String, dynamic>> fetchWorldData() async {
Response response = await get(Uri.parse(
'https://disease.sh/v3/covid-19/countries/${CurrentCountry.currentcountry}'));
return json.decode(response.body);
}
And here's my code where the method is called:
onRefresh: () {
getApiData();
}
If you can help me, I will be very grateful.