Is your feature request related to a problem? Please describe.
When the Child-Widgets in your list are Stateful, they will always be reinstantiated on parent rebuild. So if you do some async stuff inside of them it might flicker.
The problem comes from the framework not finding the elements in the tree. To tackle this the SliverChildBuilderDelegate has the findChildIndexCallback parameter which lets you return the index of the item based on it's key.
Since we have separators and the groupSeperators, the actual index of widgets inside the list is different to the list of elements. Flutter's standard SliverList.separated faces the same problem because the separators are actual widgets put into the sliver.
Right now there is also the problem that _buildItem wraps the children in a container with a GlobalKey that is never used, I guess it's an artifact from the non-sliver variant.
Widget _buildItem(context, int actualIndex) { var key = GlobalKey(); _keys['$actualIndex'] = key; return widget.indexedItemBuilder == null ? widget.itemBuilder!(context, _sortedElements[actualIndex]) : widget.indexedItemBuilder!( context, _sortedElements[actualIndex], actualIndex); }
Describe the solution you'd like
The SliverList needs a parameter like getItemByKey or something and then it could determine the actual index of that item in the sliver. I did this in my fork and now my children aren't reinstantiating every time.
Is your feature request related to a problem? Please describe.
When the Child-Widgets in your list are Stateful, they will always be reinstantiated on parent rebuild. So if you do some async stuff inside of them it might flicker.
The problem comes from the framework not finding the elements in the tree. To tackle this the SliverChildBuilderDelegate has the
findChildIndexCallbackparameter which lets you return the index of the item based on it's key.Since we have separators and the groupSeperators, the actual index of widgets inside the list is different to the list of elements. Flutter's standard SliverList.separated faces the same problem because the separators are actual widgets put into the sliver.
Right now there is also the problem that _buildItem wraps the children in a container with a GlobalKey that is never used, I guess it's an artifact from the non-sliver variant.
Widget _buildItem(context, int actualIndex) { var key = GlobalKey(); _keys['$actualIndex'] = key; return widget.indexedItemBuilder == null ? widget.itemBuilder!(context, _sortedElements[actualIndex]) : widget.indexedItemBuilder!( context, _sortedElements[actualIndex], actualIndex); }Describe the solution you'd like
The SliverList needs a parameter like
getItemByKeyor something and then it could determine the actual index of that item in the sliver. I did this in my fork and now my children aren't reinstantiating every time.