Working in a chat app. when we navigate to the individual chat screen the screen starts from the top. On googling, the recommendation was the put reverse: true,
but it just reverses the list and again starts from the top of the list. I want to start the page from the bottom as usual chat pages do.
CodePudding user response:
Attach a scroll controller to your listView.
ScrollController _scrollController = ScrollController();
add the above controller to your listview.
ListView.builder(
controller: _scrollController,
itemCount: 10,
itemBuilder: (_, i) => MyItem(i),
),
Then call the bottom function in your initState()
void _goToBottomPage() {
_scrollController.jumpTo(_scrollController.position.maxScrollExtent);
}