Programmatically scrolling to the end of a ListView

前端 未结 7 2101
既然无缘
既然无缘 2020-11-27 13:03

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

7条回答
  •  醉话见心
    2020-11-27 13:52

    you could use this where 0.09*height is the height of a row in the list and _controller is defined like this _controller = ScrollController();

    (BuildContext context, int pos) {
        if(pos != 0) {
            _controller.animateTo(0.09 * height * (pos - 1), 
                                  curve: Curves.easeInOut,
                                  duration: Duration(milliseconds: 1400));
        }
    }
    

提交回复
热议问题