grouped_list
grouped_list copied to clipboard
Bug : Header not changed once elements changed
I have a search field that filter elements, When I change elements by filtering them , sticky header (that removed by filtering) is not removed and after scrolling is removed
I had the same problem and I think is got to do with below initialData state when generating the group headers.
StreamBuilder<E>( stream: _streamController.stream, initialData: _topElementIndex, builder: (context, snapshot) => _showFixedGroupHeader(snapshot.data), ),
If you use GroupedListView within a stateful widget and your state changes (for example when changing filter elements) this _topElementIndex seemes to be pre-populated with the previous value hence showing the previous top header. It all fixes itself once you start scrolling. What I ended up doing was to create and pass the ScrollController to the GroupedListView widget and right after I changed my parent widget state I call scrollController.notifyListeners(); to manually trigger scrolling notification to re-calculate the top header group.
return GroupedListView<Point,String>(
controller: _scrollController,
);
and then
setState(() { filter = newfilter; // Here is where your widget state changes _scrollController.notifyListeners(); });