如何标记(启用/禁用)Flutter RefreshIndicator

gen*_*ser 7 flutter

我想RefreshIndicator用布尔参数标记我的。

是否可以?有什么窍门呢?因为没有太多选择...

return RefreshIndicator(
    onRefresh: () async {
        return Future.value();
    },
    backgroundColor: Colors.white,
    color: Colors.pink,
    strokeWidth: 2.75,
    child: SingleChildScrollView(...)
)
Run Code Online (Sandbox Code Playgroud)

在此输入图像描述

Sim*_*eon 18

要禁用 RefreshIndicator,请传递返回 false 的 notificationPredicate 函数。

执行此操作后,将不会显示刷新指示器或调用 onRefresh。

RefreshIndicator(
  notificationPredicate: enabled ? (_) => true : (_) => false,
  ...
);
Run Code Online (Sandbox Code Playgroud)