Dimibe/sticky_grouped_list

scrollTo, jumpTo to the last index

Opened this issue · 6 comments

If I try to jumpTo the last index

groupedItemScrollController.jumpTo(index: items.length - 1);

Can not scroll to the item because there isn't any padding on the bottom.

So it is flickering.

Even it is not the last index, some item in the middle of the end page's position, it can not scroll to that item.
Scroll will try to forcibly scroll to it but can not reach because it is already bottom of the total items.

So I think it needs

  1. some methods to get whether it is now on the limit of the scroll. (calculated from the item index)
  2. scroll to bottom. the bottom means the end of the items.
eul commented

How can I scroll to the last item?
I used animateTo(0.0,duration: Duration(milliseconds: 300), curve: Curves.easeOut); with ListView

how to scroll to last index Im having same issue where I dont have enough space to scroll to last items and it bounce back to the top

@anthonycuervo23 @eul @dmk3141618 Try this:

  groupedItemScrollController.scrollTo(
      index: itemPositionsListener.itemPositions.value.last.index,
      duration: Duration(milliseconds: 100),
  );

Please remember to add this:

itemPositionsListener: itemPositionsListener, 

to your StickyGroupedListView after its declaration, like this:

  ItemPositionsListener itemPositionsListener = ItemPositionsListener.create();

after adding

  scrollable_positioned_list: ^0.2.3

to your pubspec.yaml

Thanks @waqadArshad but I still face the same behavior no matter if is the first or last index

Screen_Recording_2022-06-23_at_11_20_53_PM_AdobeExpress

@anthonycuervo23 @eul @dmk3141618 Try this:

  groupedItemScrollController.scrollTo(
      index: itemPositionsListener.itemPositions.value.last.index,
      duration: Duration(milliseconds: 100),
  );

Please remember to add this:

itemPositionsListener: itemPositionsListener, 

to your StickyGroupedListView after its declaration, like this:

  ItemPositionsListener itemPositionsListener = ItemPositionsListener.create();

after adding

  scrollable_positioned_list: ^0.2.3

to your pubspec.yaml

@anthonycuervo23 Hi, what do u mean by "where I dont have enough space to scroll to last items". I mean why don't u have space to scroll to last item? it's a listView

I was able to resolve this issue assigning bottom padding to StickGroupedListView.