Flutter开发:ListView手动滚动到底部

这个问题搜了很久都没找到,国内关于flutter的研究好像还没多少,不过stackoverflow真的是万能的,这里记录一下~

原文

Use
ScrollController.jumpTo() or
ScrollController.animateTo() method to achieve this.

Here is code snippet (After 1 second, the
ListView will scroll to the bottom)

by
CopsOnRoad

class _HomePageState extends State<HomePage> {
  ScrollController _controller = ScrollController();

  @override
  Widget build(BuildContext context) {
    Timer(Duration(milliseconds: 1000), () => _controller.jumpTo(_controller.position.maxScrollExtent));

    return ListView.builder(  controller: _controller,  itemCount: 50,  itemBuilder: (context, index) => ListTile(title: Text("ListTile"),));
  }
}

    原文作者:DealiAxy
    原文地址: https://zhuanlan.zhihu.com/p/61380026
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞