Dimibe / sticky_grouped_list

A ScrollablePositionedList in which items can be grouped into sections with sticky headers.
https://pub.dev/packages/sticky_grouped_list
MIT License
184 stars 71 forks source link

When list is being used in reverse then jumpTo/scrollTo index 0 fails, it always takes you to index 1 #52

Open ps9310 opened 2 years ago

ps9310 commented 2 years ago

Following is my code snippet

StickyGroupedListView<Message, DateTime>(
  reverse: true,
  floatingHeader: true,
  elements: state.messages,
  order: StickyGroupedListOrder.DESC,
  itemScrollController: groupedItemScrollController,
  itemPositionsListener: itemPositionsListener,
  elementIdentifier: (message) => message.msgId,
  itemComparator: (a, b) => (a.dateTime).compareTo(b.dateTime),
  groupBy: (msg) => DateTime(msg.dateTime.year, msg.dateTime.month, msg.dateTime.day),
  groupSeparatorBuilder: (message) {
    return Text('Header');
  },
  itemBuilder: (context, message) {
    return Text('Message');
  },
)

Whenever user adds a new message, I'm calling following code to take user to first message in chat, which is taking me to index 1 instead of 0.

groupedItemScrollController.jumpTo(index: 0);