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

grouped_list gr #118

Closed KlubAndroid closed 9 months ago

KlubAndroid commented 3 years ago

Hi IM working in Flutter project, basically I query db, convert result in map, fill list with result and pass to groupView.. Everything working but, in every other group first item switch place with some other item from same group at hotrestart app or when setstate is called. If I use dummy data from example here no switching occur? Dose anyone now what cud be wrong?

  _groupView() {
    return Container(
      child: GroupedListView<dynamic, String>(
        shrinkWrap: true,
        elements: questionsBooks,
        groupBy: (element) => element['Category'],
        separator: Divider(),
        groupComparator: (value1, value2) {
          return value1.compareTo(value2);
        },
        groupSeparatorBuilder: (value) {
          return Text(
            value.toString(),
          );
        },
        indexedItemBuilder: (context, element, index) {
          return CheckboxListTile(
            value: true,
            contentPadding: EdgeInsets.symmetric(horizontal: 8.0),
            title: Text(
              element['Description'],
            ),
            onChanged: (bool? value) {

              }
            },
          );
        },
      ),
    );
  }
Future<void> _getData() async {
    List<Map<String, dynamic>> result = await dbService.getRelatedTo();

    if (result.isNotEmpty) {
      var map = new Map<String, dynamic>();
      for (int i = 0; i < result.length; i++) {
        map['Description'] = result[i]['Description'].toString();
        map['Category'] = result[i]['Category'].toString();

        questionsBooks.add(Map<dynamic, String>.from(map));
      }
    }
  }

GetData is caled in initState, so every time i hot reload app or rebuild, grouping item first in second group is changed to some other if reload again all get back to normal? Strange, i cud need any help ty.

KlubAndroid commented 3 years ago

I was able to reproduce bug, it seams that error is only if list is longer than 32...

Dimibe commented 9 months ago

Closing this in favor of #167