Dimibe/sticky_grouped_list

How to Check If Scroll Position is Top or Bottom?

AsadAMalikDeveloper opened this issue · 4 comments

How to Check If Scroll Position is Top or Bottom?

Use GroupedItemScrollController

  final GroupedItemScrollController itemScrollController =
      GroupedItemScrollController();

itemPositionsListener.itemPositions.addListener(() {
      if (itemPositionsListener.itemPositions.value.last.index ==
          itemsPosition) {
//run your code
}});

From where we get item position ?

I used Notification Listener (ScrollUpdateNotification)

bool scrollListner(ScrollUpdateNotification scrollEnd) {
    if (scrollEnd.metrics.pixels > scrollEnd.metrics.maxScrollExtent ) {
      reached top (if reverse is true)
    } else if (scrollEnd.metrics.pixels <
        scrollEnd.metrics.minScrollExtent) {
      print('Reached bottom');
    }
    return true;
  }