Flutter 如何使FixedExtentScrollController animateToItem方法仅在一个方向上设置滚动动画?(颤振)
我正在尝试使用Flutter 如何使FixedExtentScrollController animateToItem方法仅在一个方向上设置滚动动画?(颤振),flutter,dart,flutter-animation,dart-pub,Flutter,Dart,Flutter Animation,Dart Pub,我正在尝试使用ListWheelScrollView.useDelegate()方法创建类似于老虎机的行为。以下是我目前掌握的情况: final FixedExtentScrollController\u controller=FixedExtentScrollController(); ... ListWheelScrollView.useDelegate( 控制器:_控制器, 物理:NeverScrollableScrollPhysics(),//用户将无法手动滚动 项目范围:50, chi
ListWheelScrollView.useDelegate()
方法创建类似于老虎机的行为。以下是我目前掌握的情况:
final FixedExtentScrollController\u controller=FixedExtentScrollController();
...
ListWheelScrollView.useDelegate(
控制器:_控制器,
物理:NeverScrollableScrollPhysics(),//用户将无法手动滚动
项目范围:50,
childDelegate:ListWheelChildLoopingListDelegate(
孩子们:模特。所有浇头
.地图(
(顶部)=>容器(
颜色:color.fromRGBO(0,0,0,0.5),
身高:50,
宽度:50,
子项:Image.asset(top.Image),
),
)
.toList(),
),
),
我有一个“旋转”按钮,当点击时,它会以编程方式将ListWheelScrollView
滚动到随机项
void userClickedSpin(){
最终随机数=新随机数();
最终int randomIndex=random.nextInt(allToppings.length);
controller.animateToItem(
随机指数,
持续时间:持续时间(毫秒:300),
曲线:Curves.FastOutSwowin,
);
}
问题是当我想要像吃角子老虎机那样只向一个方向旋转的行为时,animateToItem
方法会向两个方向滚动。如何做到这一点
欢迎您的任何意见。谢谢大家!