xuelongqy / flutter_easy_refresh

A flutter widget that provides pull-down refresh and pull-up load.
https://xuelongqy.github.io/flutter_easy_refresh/
MIT License
3.89k stars 633 forks source link

多次执行callRefresh,callRefresh只会走第一次,后面的都不会走 #802

Closed Darren-chenchen closed 5 months ago

Darren-chenchen commented 8 months ago

多个tab来回点击,或者点击一个tab,当refresh还没停止时,点击另外一个tab。

onTap: (int? index) {
     store.currentIndex = index ?? 0;
     print(index);
     store.controller.callRefresh();
},

例如:我点击第2个tab,此时print: 2, callRefresh正在执行, 我又点击了第3个tab。此时打印print: 3, 但是并没有看到接口请求tab=3的网络请求。

easy_refresh: ^3.3.2+1 flutter:3.16.2

目前临时的解决方案是: 1、监听tab的改变, 只要改变就掉接口

_tabController?.addListener(() {
       store.loadList();
  });

2、tab点击的时候,同时执行,主要想使用callRefresh的自动下拉效果,不想界面上加loading

onTap: (int? index) {
        store.currentIndex = index ?? 0;
        store.controller.callRefresh();
      },

3、这样会产生网络多次调用情况。在网络请求处加防抖

loadList() async {
    try {
      EasyDebounce.debounce('myworklistid', const Duration(milliseconds: 300),
          () async {
        var res = await ArticleRepository.getMyPlaylist(
            currentCate.name ?? '默认',
            userId: currentWork?.userId);
        }
      });
    } catch (e) {
      controller.finishRefresh();
    }
  }
xuelongqy commented 8 months ago

你可以给不同的Tab页分别设置不用ScrollController。不设置的话默认会用同一个

xuelongqy commented 5 months ago

如果还有问题,请重新开启此issue