superlistapp / super_sliver_list

Drop-in replacement for SliverList and ListView that can handle large amount of items with variable extents and reliably jump / animate to any item.
https://superlistapp.github.io/super_sliver_list/
MIT License
277 stars 15 forks source link

Unreliable Scroll Notifications #64

Open ibrahimdevs opened 2 months ago

ibrahimdevs commented 2 months ago

@knopp When we use SuperListView in a NotificationListener, and call animateToItem with ListController. There are many ScrollStart, ScrollUpdate and ScrollEnd notifications fired. There should be only one ScrollStart, many ScrollUpdate and one ScrollEnd like ListView.

listController.animateToItem(
                    index: focusedItemIndex,
                    scrollController: scrollController,
                    alignment: 0.5,
                    duration: (estimatedDistance) => Duration(milliseconds: 250),
                    curve: (estimatedDistance) => Curves.easeInOut,
                  );

NotificationListener<ScrollNotification>(
            onNotification: (ScrollNotification scrollInfo) {
              if (scrollInfo.depth > 0) {
                print("scrollInfo.depth > 0");
                return false;
              }
              if (scrollInfo is ScrollEndNotification) {
                //It should only fired when scroll ends.
              }
              return true;
            },
            child: SuperListView.builder(
              controller: scrollController,
              listController: listController,
              itemBuilder: (context, int){
                return AnimatedOpacity(
                  duration: Duration(milliseconds: 250),
                  opacity: index == focusedItemIndex ? 1.0 : 0.5,
                  child: Text("${itemList[index]}"),
                );
              },
              itemCount: itemList.length,
              physics: ClampingScrollPhysics(),
            ),
          );