Issue
If I add items dynamically to a listView with a listView.builder, how do I keep the bottom of the list focus ? Like if the list is full, and I add an Item, how do I do to make the other go up and focus the last item without deleting anything ?
Solution
Hi you can take help of ScrollController
using method jumpTo()
or animateTo()
like bellow,
First create instance of
ScrollController controller = new ScrollController();
Then after registering it with your listview like bellow example
ListView.builder(
itemBuilder: (context, index) => ListTile(
title: Text("Item List"),
),
controller: controller,
itemCount: 50,
),
And finally call jumTo() or animateTo()
method when new item added or whenever you want to go at bottom like bellow
controller.jumpTo(controller.position.maxScrollExtent);
Answered By - Dhaval Solanki
Answer Checked By - Marilyn (JavaFixing Volunteer)