【发布时间】:2021-04-25 14:54:29
【问题描述】:
我正在使用RefreshIndicator从互联网刷新数据,但是当我从顶部下拉时,刷新图标没有消失,也出现错误:
════════ 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.
════════════════════════════════════════════════════════════════════════════════
这是我的代码,其中声明了获取数据的方法:
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);
}
这是我调用该方法的代码:
onRefresh: () {
getApiData();
}
如果你能帮助我,我将非常感激。
【问题讨论】: