'Flutter Scrollcontroller maxScrollExtent doesn't go till the end of list

it stops before last element in list. Is there a way to go till the end container of the last element

        controller
          ..animateTo(
            controller.position.maxScrollExtent,
            curve: Curves.easeIn,
            duration: const Duration(milliseconds: 300),
          );
      });```






Solution 1:[1]

Using Without Animation Solved the Problem

Timer(Duration(milliseconds: 500), () {
        controller.jumpTo(controller.position.maxScrollExtent);
      });

Solution 2:[2]

I think this is the best function to scroll to bottom with a good animation

scrollToBottom() {
if (_chatController.hasClients) {
      Future.delayed(const Duration(milliseconds: 500)).then((value) {
        _chatController.animateTo(
          _chatController.position.maxScrollExtent,
          duration: const Duration(milliseconds: 200),
          curve: Curves.fastOutSlowIn,
        );
      });
    }
}

Solution 3:[3]

In my case the problem was that the elements were not equal in size and the size was not known until rendered. So, the ListView scrolled to its initial estimated maxScrollExtent but while scrolling the elements were rendered and the new maxScrollExtent was bigger. I hacked it by giving it a much bigger value initially:

attachmentsScrollController.animateTo(
  attachmentsScrollController.position.maxScrollExtent * 2,
  duration: Duration(milliseconds: 300),
  curve: Curves.easeInOut);

Solution 4:[4]

What worked with me is this:

 void scrollAnimateToEnd(ScrollController controller) {
Future.delayed(const Duration(milliseconds: 400)).then((_) {
  try {
    controller
        .animateTo(
      controller.position.maxScrollExtent,
      duration: const Duration(seconds: 1),
      curve: Curves.fastOutSlowIn,
    )
        .then((value) {
      controller.animateTo(
        controller.position.maxScrollExtent,
        duration: const Duration(milliseconds: 200),
        curve: Curves.easeInOut,
      );
    });
  } catch (e) {
    print('error on scroll $e');
  }
});

}

Solution 5:[5]

I had same problem with CustomeScrollView widget, and I solved with this.

CustomScrollView(
                  controller: Get.find<ChatController>(tag: 'chatDetail')
                      .scrollController
                      .value,
                  reverse: true,
                  keyboardDismissBehavior:
                      ScrollViewKeyboardDismissBehavior.onDrag,
                  physics: ClampingScrollPhysics(),
                  cacheExtent: 99999, // <-- here !!! ADD THIS CODE
                  slivers: [
                    ChatList(
                      isQuestion: isQuestion,
                      postCreatedAt: postCreatedAt,
                      title: title,
                    ),
                  ],
                ),

my scroll function was normal as we talked before.

 void chatScrollUp() async {
await scrollController.value.animateTo(
    scrollController.value.position.maxScrollExtent,
    duration: Duration(
        milliseconds:
            (scrollController.value.position.maxScrollExtent / 2).round()),
    curve: Curves.easeOutCirc);}

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 LIONEL VSV
Solution 2 Chand Abdullah
Solution 3 AXE
Solution 4 Aziz
Solution 5 Donghyun Won