loading_more_list icon indicating copy to clipboard operation
loading_more_list copied to clipboard

[Bug report] 一個頁面有多個LoadingMoreSliverList, 第一個list的indicatorBuilder不會觸發IndicatorStatus.noMoreLoad

Open aboyo opened this issue 1 year ago • 14 comments

Version

6.0.0

Platforms

dart

Device Model

iPhone 15 Pro

flutter info

Flutter (Channel stable, 3.22.0, on macOS 14.4 23E214 darwin-arm64, locale zh-Hant-TW)
    • Flutter version 3.22.0 on channel stable at /Users/abo/fvm/versions/3.22.0
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 5dcb86f68f (6 weeks ago), 2024-05-09 07:39:20 -0500
    • Engine revision f6344b75dc
    • Dart version 3.4.0
    • DevTools version 2.34.3

How to reproduce?

一個頁面有多個LoadingMoreSliverList的話,第一個list的indicatorBuilder不會觸發IndicatorStatus.noMoreLoad。 兩個list應該要有各自獨立的行為對嗎? 還是該如何正確的使用~?

Logs

No response

Example code (optional)

LoadingMoreCustomScrollView(
              physics: hasData ? const BouncingScrollPhysics() : const NeverScrollableScrollPhysics(),
              slivers: [
                LoadingMoreSliverList<String>(
                  SliverListConfig<String>(
                    extendedListDelegate: SliverWaterfallFlowDelegateWithMaxCrossAxisExtent(
                      maxCrossAxisExtent: MediaQuery.of(context).size.width / 2,
                      crossAxisSpacing: 12,
                      mainAxisSpacing: 12,
                    ),
                    itemBuilder: (context, title, index) {
                      return Item(title: title);
                    },
                    sourceList: sourceList1,
                    padding: const EdgeInsets.all(12),
                    lastChildLayoutType: LastChildLayoutType.foot,
                    indicatorBuilder: (context, status) {
                      print(status);
                      return SomeWidget();
                    },
                  ),
                ),
                LoadingMoreSliverList<String>(
                  SliverListConfig<String>(
                    extendedListDelegate: SliverWaterfallFlowDelegateWithMaxCrossAxisExtent(
                      maxCrossAxisExtent: MediaQuery.of(context).size.width / 2,
                      crossAxisSpacing: 12,
                      mainAxisSpacing: 12,
                    ),
                    itemBuilder: (context, title, index) {
                      return Item(title: title);
                    },
                    sourceList: sourceList2,
                    padding: const EdgeInsets.all(12),
                    lastChildLayoutType: LastChildLayoutType.foot,
                    indicatorBuilder: (context, status) {
                      print(status);
                      return SomeWidget();
                    },
                  ),
                ),
              ],
            );

Contact

No response

aboyo avatar Jun 17 '24 15:06 aboyo

有个参数,默认是 中间的都不显示,你可以自己改下

zmtzawqlp avatar Jun 18 '24 01:06 zmtzawqlp

有个参数,默认是 中间的都不显示,你可以自己改下

hi, 你是說showNoMore嗎?我將showNoMore設成true有顯示, 另外請問一下,當我滑到底至第二個list時,我發現在二個list的IndicatorStatus沒有觸發loading的狀態

aboyo avatar Jun 18 '24 07:06 aboyo

因为第2个不适合全屏幕的loading呢。。直接用的小loading

zmtzawqlp avatar Jun 18 '24 11:06 zmtzawqlp

因为第2个不适合全屏幕的loading呢。。直接用的小loading

是的,但我測試滑到第二個list時,第二個list的indicatorBuilder沒有觸發(沒有小loading),過一下子data會直接出現,繼續往下滑時load more時才有IndicatorStatus.loadingMoreBusying

aboyo avatar Jun 18 '24 11:06 aboyo

没有重现。你直接说需求。或者自己debug 下过程。

https://github.com/fluttercandies/loading_more_list/blob/9afe699fbd49f8793f319a40a672d6a8f455a9dd/lib/src/loading_more_sliver_list.dart#L329

zmtzawqlp avatar Jun 18 '24 14:06 zmtzawqlp

没有重现。你直接说需求。或者自己debug 下过程。

https://github.com/fluttercandies/loading_more_list/blob/9afe699fbd49f8793f319a40a672d6a8f455a9dd/lib/src/loading_more_sliver_list.dart#L329

我的需求是:當滑到第二個list時,最一開始載入list2也能顯示小loading(IndicatorStatus.loadingMoreBusying的loading),讓滑動的感覺有接續第一個list的效果,我剛剛有看了下程式碼, 跟你確認下: https://github.com/fluttercandies/loading_more_list/blob/9afe699fbd49f8793f319a40a672d6a8f455a9dd/lib/src/loading_more_sliver_list.dart#L319-L334 這邊應該是第二個sliver及之後,呼叫refresh()時,notifyStateChanged預設是false(要為true才會有loading狀態及效果),但由於非第一個sliver,不適合全螢幕的loading,所以 https://github.com/fluttercandies/loading_more_list_library/blob/6fd12633097953544732f46cff94f6b10bf4e3b2/lib/src/loading_more_list_library.dart#L72-L81 這邊要多判斷一個參數來決定indicatorStatus要為IndicatorStatus.fullScreenBusying還是 IndicatorStatus.loadingMoreBusying

可以由: https://github.com/fluttercandies/loading_more_list/blob/9afe699fbd49f8793f319a40a672d6a8f455a9dd/lib/src/loading_more_sliver_list.dart#L313 這邊的index來知道是否非第一個sliver,我這樣理解對嗎~?

aboyo avatar Jun 18 '24 16:06 aboyo

你第2个列表全屏幕loading 用 loading more 多ui 就好了

zmtzawqlp avatar Jun 19 '24 01:06 zmtzawqlp

你第2个列表全屏幕loading 用 loading more 多ui 就好了

什麼意思~?

aboyo avatar Jun 19 '24 01:06 aboyo

fullScreenBusying 换成 loadingMoreBusying 的ui

zmtzawqlp avatar Jun 19 '24 01:06 zmtzawqlp

fullScreenBusying 换成 loadingMoreBusying 的ui

好的 我試下 感謝

aboyo avatar Jun 19 '24 03:06 aboyo

我再請問下~ 目前我的list2等於是依賴list1(list1滑到底後才開始載入list2),當我下拉刷新時(刷新list1),我的list2想要清空,變成回到一開始的狀態(list1滑到底,換list2開始載入), 我試過在list1 refresh()時,將list2 clear(),但不起作用(如影片)

https://github.com/fluttercandies/loading_more_list/assets/21969308/033bfcae-7e1e-414f-a5ba-e3be14beda9e

請問refresh list1時,該怎麼將list2 reset~?

aboyo avatar Jun 20 '24 05:06 aboyo

下啦刷新。重新new configs。 除了clear 你还需要通知ui 更新。你可以看看代码 onstatechanged

zmtzawqlp avatar Jun 20 '24 05:06 zmtzawqlp

下啦刷新。重新new configs。 除了clear 你还需要通知ui 更新。你可以看看代码 onstatechanged

觸發onstatechanged的是setState方法對嗎:

/// update ui
  void setState() {
    super._onStateChanged(this);
  }

但我剛剛實測我自己在繼承於LoadingMoreBase的controller中宣告的reset()方法

void reset() {
    _hasMore = true;
    _pageIndex = 1;
    clear();
    indicatorStatus = IndicatorStatus.fullScreenBusying;
  }

這樣子看起來是可以(不用呼叫setState()也可以),

https://github.com/fluttercandies/loading_more_list/assets/21969308/872b5dc4-f649-4808-8db7-eab88749e59a

但你有註解:

//do not change this in out side
 IndicatorStatus indicatorStatus = IndicatorStatus.fullScreenBusying;

aboyo avatar Jun 20 '24 06:06 aboyo

下啦刷新。重新new configs。 除了clear 你还需要通知ui 更新。你可以看看代码 onstatechanged

觸發onstatechanged的是setState方法對嗎:

/// update ui
  void setState() {
    super._onStateChanged(this);
  }

但我剛剛實測我自己在繼承於LoadingMoreBase的controller中宣告的reset()方法

void reset() {
    _hasMore = true;
    _pageIndex = 1;
    clear();
    indicatorStatus = IndicatorStatus.fullScreenBusying;
  }

這樣子看起來是可以(不用呼叫setState()也可以),

2024-06-20.2.54.09.mp4 但你有註解:

//do not change this in out side
 IndicatorStatus indicatorStatus = IndicatorStatus.fullScreenBusying;

可以就行。影响不大,只是不希望外部随意就改变。你知道流程就无所谓

zmtzawqlp avatar Jun 20 '24 07:06 zmtzawqlp