Dimibe / grouped_list

A Flutter ListView in which items can be grouped into sections.
https://pub.dev/packages/grouped_list
MIT License
395 stars 106 forks source link

Order Descending Grouped Dates #106

Closed saguado69 closed 2 years ago

saguado69 commented 3 years ago

Hi,

My code was runnning ok with previous versión of 4.0.0. After upgrading I lost scending ordenring of the groups. Items still ordenring descending but not the groups. If I only order by MMM yyyy is ok but if I order by dd MMMM yyyy then the groups order does not work. I have tryied differents combination with comparator but not succeed.

GroupedListView(
                      key: const Key('changeLogGroupedList'),
                      elements: logItems,
                      floatingHeader: true,
                      addAutomaticKeepAlives: true,
                      useStickyGroupSeparators: true,
                      groupBy: (dynamic logItem) => DateFormat('dd MMMM yyyy')
                          .format(logItem.createdAt.toDate()),
                      groupComparator: (value1, value2) =>
                          value2.compareTo(value1),
                      itemComparator: (item1, item2) =>
                          item1.createdAt.compareTo(item2.createdAt),
                      order: GroupedListOrder.DESC,
                      groupSeparatorBuilder: (dynamic logItem) => SizedBox(
DineshKachhot commented 2 years ago

I have the same kind of issue using grouped_list, I am not able to order groups by date.

DineshKachhot commented 2 years ago

My issue is fixed: if you are displaying an ordered list, you can disable sorting of GroupedListView like sort: false. I am not sure it will help any one, but sharing here as it worked for me.

nifhanif commented 2 years ago

Thank you... it work

My issue is fixed: if you are displaying an ordered list, you can disable sorting of GroupedListView like sort: false. I am not sure it will help any one, but sharing here as it worked for me.

Dimibe commented 2 years ago

Seems to be solved

waqadArshad commented 2 years ago

My issue is fixed: if you are displaying an ordered list, you can disable sorting of GroupedListView like sort: false. I am not sure it will help any one, but sharing here as it worked for me.

Thanks a lot @DineshKachhot

lakoliu commented 1 year ago

Thank you, @DineshKachhot, that was just what I needed!