grouped_list icon indicating copy to clipboard operation
grouped_list copied to clipboard

Bug : Header not changed once elements changed

Open sm2017 opened this issue 5 years ago • 1 comments

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

sm2017 avatar Jul 21 '20 06:07 sm2017

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(); });

velval avatar Oct 16 '20 05:10 velval