我的意思是检查刷新指示器是否正在刷新。在该值为true时基于该值采取行动以阻止微调框旋转。
Widget _productLogic(MainModel model) {
Widget content = Center(
child: Text("No products available."),
);
if (model.allProduct.length > 0 && !model.isLoading) {
content = _buildProductList(model.allProduct);
} else if (model.isLoading) {
content = Center(
child: CircularProgressIndicator(),
);
}
return RefreshIndicator(
child: content,
onRefresh: model.fetchProducts,
backgroundColor: Colors.blue,
color: Colors.red);
}
@override
Widget build(BuildContext context) {
return ScopedModelDescendant<MainModel>(
builder: (BuildContext context, Widget child, MainModel model) {
return _productLogic(model);
});
}
答案 0 :(得分:0)
实际上,您必须将全局密钥设置为RefreshIndicator
并选中currentState
,如下所示
final GlobalKey<RefreshIndicatorState> _refreshKey =
new GlobalKey<RefreshIndicatorState>();
然后
return RefreshIndicator(
key: _refreshKey,
然后
_refreshKey.currentState?.show()?.then((_) {......