Flutter:Scrolling To Bottom Automatically when the screen opens

后端 未结 1 1430
感动是毒
感动是毒 2021-02-09 18:57

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:08

    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)
提交回复
热议问题