Flutter开发:ListView手动滚动到底部
这个问题搜了很久都没找到,国内关于flutter的研究好像还没多少,不过stackoverflow真的是万能的,这里记录一下~
原文
Use
ScrollController.jumpTo()
orScrollController.animateTo()
method to achieve this. Here is code snippet (After 1 second, theListView
will scroll to the bottom) by CopsOnRoadclass _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"),)); } }
欢迎交流
交流问题请在微信公众号后台留言,每一条信息我都会回复哈~ - 微信公众号:画星星高手 - 打代码直播间:https://live.bilibili.com/11883038 - 知乎:https://www.zhihu.com/people/dealiaxy - 简书:https://www.jianshu.com/u/965b95853b9f