一、定義ScrollController控制器變數
ScrollController _controller = ScrollController();
二、為ListView添加控制器
SizedBox(
child: ListView.builder(
controller:_controller,
physics: const BouncingScrollPhysics(),
itemCount: eList.length,
itemBuilder: (BuildContext context, int a) {
return getRow(a);
}),
height: (72.h * (eList.length)<=216.h)?72.h * (eList.length):216.h),
三、使用控制器進行跳轉
_controller.animateTo((eList.length-3)*72.h, duration: Duration(milliseconds: 300), curve:Curves.ease);
四、關閉控制器
_controller.dispose();
轉載請註明出處,本文鏈接:https://www.uj5u.com/yidong/292207.html
標籤:其他
