Flutter: Listview get full size of scrollcontroller after adding item to list & scroll to end

前端 未结 2 1847
慢半拍i
慢半拍i 2021-01-15 08:11

This post describes a very similar problem, but the answer there doesn\'t solve all problems:

I have a potentially long List, where the user can add new items (on at

2条回答
  •  醉话见心
    2021-01-15 08:44

    Specifying a too large scrollPosition works without errors, the ScrollController then automatically scrolls to the final maximum value. I define a _scrollController and execute the following command:

    _scrollController.animateTo(
        _scrollController.position.maxScrollExtent + 200,
        duration: const Duration(milliseconds: 350),
        curve: Curves.easeOut);
    

    or

    _scrollController.jumpTo(_scrollController.position.maxScrollExtent + 200);
    

提交回复
热议问题