【问题标题】:Flutter ListView touch listenerFlutter ListView 触摸监听器
【发布时间】:2019-01-19 16:42:43
【问题描述】:

在滚动ListView 后,我如何才能发现用户已将手指从屏幕上移开。我想在此事件发生时使用ScrollController.jumpTo(...)。而且我找不到这样的回调。

PS:我尝试使用GestureDetector,但没有任何效果。

【问题讨论】:

    标签: dart flutter


    【解决方案1】:

    我发现了。

    ScrollController.position.isScrollingNotifier.addListener(() {// scrolling stopped});
    

    如果有人知道更好的解决方案,请写下来。我非常乐意接受您的回答。

    【讨论】:

      【解决方案2】:

      ListView 包裹在NotificationListener 中并监听UserScrollNotification

      NotificationListener<UserScrollNotification>(
        onNotification: (notification) {
          if (notification.direction == ScrollDirection.idle) {
            print("Scrolling stopped");
          }
        },
        child: ListView.builder(...),
      ),
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2014-07-08
        • 1970-01-01
        • 2019-01-27
        • 2017-05-18
        • 1970-01-01
        • 2012-01-27
        • 1970-01-01
        相关资源
        最近更新 更多