Flutter:Scrolling To Bottom Automatically when the screen opens

后端 未结 1 1509
陌清茗
陌清茗 2021-02-09 18:41

I\'m using onpressed() to scroll down to bottom of the List view, but i want to achieve that without Pressing the botton,

It must autoscroll for

1条回答
  •  臣服心动
    2021-02-09 19:16

    When building your ListView or adding an item (not sure how you're doing it), use SchedulerBinding.instance.addPostFrameCallback to change the scroll position on the next frame.

    SchedulerBinding.instance.addPostFrameCallback((_) {
      controller1.animateTo(
        controller1.position.maxScrollExtent,
        duration: const Duration(milliseconds: 10),
        curve: Curves.easeOut,);
      });
    }
    

    0 讨论(0)
提交回复
热议问题