I have a scrollable ListView
where the number of items can change dynamically. Whenever a new item is added to the end of the list, I would like to programmatic
I have so much problem trying to use the scroll controller to go to the bottom of the list that I use another approach.
Instead of creating an event to send the list to the bottom, I change my logic to use a reversed list.
So, each time I have a new item, I simply, made at insert at the top of the list.
// add new message at the begin of the list
list.insert(0, message);
// ...
// pull items from the database
list = await bean.getAllReversed(); // basically a method that applies a descendent order
// I remove the scroll controller
new Flexible(
child: new ListView.builder(
reverse: true,
key: new Key(model.count().toString()),
itemCount: model.count(),
itemBuilder: (context, i) => ChatItem.displayMessage(model.getItem(i))
),
),