返回文章列表文章索引阅读全文
STARBLOG / 阅读手记
Flutter

Flutter Development: Manually Scrolling a ListView to the Bottom

I searched for this problem for a long time and couldn't find it. There doesn't seem to be much Flutter research in China yet, but Stack Overflow is truly all-powerful. Recording it here~ Original Use ScrollController.jumpTo() or ScrollController.animateTo() method to achieve this. Here is code snippet (After 1 second, the ListV

曦远 (DealiAxy)约 4 分钟
目录2 个章节

I searched for this problem for a long time and couldn't find it. There doesn't seem to be much Flutter research in China yet, but Stack Overflow is truly all-powerful. Recording it here~

Original

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

Welcome to Discuss

If you have questions, please leave a message in the WeChat official account backend. I'll reply to every message~

_EOF_

Flutter Development: Manually Scrolling a ListView to the Bottom

本文作者:
程序设计实验室
版权声明:
本博客所有文章除特别声明外,均采用 BY-NC-SA 许可协议。转载请注明出处!

相关文章

有模有样解决Flutter里Webview无法访问HTTP页面的问题

探索过程 Android9(好像是吧)开始谷歌就默认不让开发者访问不安全HTTP内容了,如果非要用HTTP,那必须在networkSecurityConfig里配置cleartextTrafficPermitted才行。谷歌这个设计的出发点本是好的,HTTPS固然更安全咱都懂,但有时候这个后端接口你选择不了要HTTP还是HTTPS,比如要使用没有提供HTTPS的第三方服务,或者是本文的这种情况:在

2021-12-18 · Flutter · 约 1 分钟

Flutter移动应用快速构建实践——状态管理、国际化、数据持久化、性能优化(二)

继续上一篇:极简诗词开发背后:Flutter移动应用快速构建实践——状态管理、国际化、数据持久化、性能优化(一) 前文中说到了项目结构、状态管理和国际化的方案,本文继续聊聊数据持久化和粗略的性能优化。 数据持久化 目前的话,flutter用的比较多比较成熟的数据持久化就是shared_preferences和SQFLite,一个是ini配置文件,一个是SQLite数据库,小应用我比较倾向只用前者,

2021-12-18 · Flutter · 约 1 分钟

讨论

共 0 条

良言一句三冬暖,恶语伤人六月寒。

加载评论中…