I am trying to use the findChildIndexCallback
to keep the state of my StatefulWidgets
inside a ListView.builder
.
Can someone please provide an example of how can i actually "find" the Listview
children ?
My question directly comes from an issue i have made and that was actually fixed by the Flutter team.
Here is my code so far that is not working :
ListView.builder(
itemCount: model.messagesList.length,
findChildIndexCallback: (key) {
// final ValueKey<String> valueKey = key as ValueKey<String>;
// return model.messagesList.indexWhere((element) => element.uid == valueKey.value); // Doesn't change anything, my widgets are all rebuilt on insert
},
itemBuilder: (context, index) {
DMessage message = model.messagesList[index];
return MessageItem(
key: ValueKey<String>(message.uid)
message: message
);
}),