【问题标题】:Flutter - How to start a listview directly from bottom without animations?Flutter - 如何在没有动画的情况下直接从底部启动列表视图?
【发布时间】:2019-12-14 20:13:42
【问题描述】:

我正在创建一个颤振聊天应用程序,一旦用户进入聊天,我希望它从底部开始(最近的聊天),但我似乎找不到没有任何过渡/动画的解决方案页面加载后太糟糕了。
这是我现在使用的:

var _listController = ScrollController();
override
  void initState() {
    SchedulerBinding.instance.addPostFrameCallback((_) {
      _listController.animateTo(_listController.position.maxScrollExtent,
          duration: Duration(milliseconds: 100), curve: Curves.easeIn);
    });
    super.initState();
}

ListView.builder(
              controller: _listController,
              physics: ScrollPhysics(),
              shrinkWrap: true,
              itemCount: Provider.of<Chat>(context).chatSize,
              itemBuilder: (BuildContext context, int index) {
                return something

我也试过了:

      _listController.jumpTo(_listController.position.maxScrollExtent);

结果相同。

【问题讨论】:

    标签: flutter dart


    【解决方案1】:

    您可以为自下而上的列表添加reverse: true 属性。

    【讨论】:

      猜你喜欢
      • 2015-09-24
      • 1970-01-01
      • 1970-01-01
      • 2021-09-06
      • 2021-12-11
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多