flutter_easy_refresh icon indicating copy to clipboard operation
flutter_easy_refresh copied to clipboard

调用refreshController.finishLoad(IndicatorResult.noMore)之后,还是会触发onLoad回调,是正常的吗

Open KaiLiDev opened this issue 11 months ago • 3 comments
trafficstars

调用refreshController.finishLoad(IndicatorResult.noMore)之后,foot显示“已全部加载”,但还是会触发onLoad回调,就是如此设计的吗?还是我使用有问题?

KaiLiDev avatar Dec 09 '24 03:12 KaiLiDev

我也遇到了这个问题,调用refreshController.finishRefresh()之后设置refreshController.finishLoad(IndicatorResult.noMore)不生效

GP-Y avatar Dec 10 '24 10:12 GP-Y

我也遇到了这个问题,调用refreshController.finishRefresh()之后设置refreshController.finishLoad(IndicatorResult.noMore)不生效

我现在暂时做了逻辑上的限制,防止再次触发上拉加载;

KaiLiDev avatar Dec 13 '24 06:12 KaiLiDev

以加载失败为例子,在失败的时候,大多数人会这样使用:

 _controller.finishLoad(IndicatorResult.fail, true);
 setState(() => _error = e);

这样是不行的.

我们需要使用addPostFrameCallback在回调里面,只需要调用controller方法就行了,然后只需要通过controller的state去拿result就行了:

      WidgetsBinding.instance.addPostFrameCallback((timeStamp) {
        _controller.finishLoad(IndicatorResult.fail, true);
      });

最后最关键的一步,收起加载结束的状态:

EasyRefresh(
      controller: _controller,
      header: widget.header ?? const CupertinoHeader(),
      footer: widget.footer ?? CupertinoFooter(infiniteOffset: _controller.footerState?.result == IndicatorResult.fail ? null : 60),
      ....

TheMelody avatar Apr 07 '25 09:04 TheMelody