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 {
  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"),));
  }
}

你可能感兴趣的:(Flutter开发:ListView手动滚动到底部)