I created a design for a chat application, and tried to scroll to end automatically, I used this code
scrollController.animateTo(
scrollController.position.maxScrollExtent,
curve: Curves.easeOut,
duration: const Duration(milliseconds: 500),
);
nothing happens, ofc the list has the controller applied
child: ListView.builder(
padding: EdgeInsets.symmetric(vertical: 10),
shrinkWrap: true,
controller: scrollController,
itemCount: chatMessage.length,
itemBuilder: (context, index) {
return ChatBubble(
chatMessage: chatMessage[index],
isDark: widget._isDark,
);
},
)
I tried to print the maxScrollExtent to see if something was wrong. Both the max and min scrollExtent are equals to 0.0. The animateTo function is also call in a postFrameCallback. The listview length is always 20 has, for now, it's a simple list.
For me, the issue was that my ListView was inside a ScrollView. Removing the ScrollView fixed the issue.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With