flutter - 当我使用NotificationListener时,RefreshIndicator在flutter中不起作用

标签 flutter dart

我尝试将 RefreshIndicator 与 NotificationListener 一起使用,但它不起作用。

基本上我希望分页和拉动刷新都在同一屏幕上工作。

提前致谢!

最佳答案

您基本上必须将 RefreshIndicator 放入 NotificationListener 中。

示例:

return NotificationListener<ScrollEndNotification>(
  onNotification: (scrollEnd) {
    final metrics = scrollEnd.metrics;
    if (metrics.atEdge) {
      bool isTop = metrics.pixels == 0;
      if (!isTop) {
        loadMessages();
      }
    }
    return true;
  },
  child: RefreshIndicator(
    onRefresh: () async => setFutures(),
    child: SingleChildScrollView(
      child: MessagesFeed(
        loadMore: loadMessages,
        key: _messageFeedKey,
        messages: snapshot.data!,
        answers: false,
        messageId: -1,
      ),
    ),
  )
);

关于flutter - 当我使用NotificationListener时,RefreshIndicator在flutter中不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/70603838/

相关文章:

firebase - Flutter Firebase Realtime数据库获取单个数据查询结果值null

Flutter:ListView禁用触摸屏滚动

flutter - 无法将列表嵌套在ExpansionTileCard中

flutter - 如何在 flutter 中反复更新倒数计时器

flutter - 颤音短信功能在构建APK时不起作用

在构建中无限调用 Flutter 函数

flutter - 在 Flutter 中使用特定于平台的包

flutter - 如何在没有错误的情况下缩小 parent 忽略 child 的大小

flutter - 如何在不使 main() 异步的情况下将异步对象注册到 get_it 包?

go - Flutter,在预构建的 GO .so 库上使用 DynamicLibrary.open(),无需编写 Native Code(Java/Swift)