如何使RotateTransition将小部件旋转一半(180度)



如何使用RoatateTransition使小部件旋转到特定程度:我的代码如下:

AnimationController _animationController;

@override
void initState() {
super.initState();
_animationController = AnimationController(vsync: this, duration: Duration(seconds: 1));
_animationController.repeat();
}
RotationTransition(
turns: this.animationController,
child: Icon(Icons.arrow_drop_down_sharp, color: Colors.white, size: 25,)
)

但我的问题是,代码不断地旋转,我很想让它旋转到特定的程度,然后反转回来。

您需要像一样定义

AnimationController  _animationController = AnimationController(
duration: const Duration(seconds: 1),
vsync: this,
value: 0,
lowerBound: 0,
upperBound: 0.5
);
Animation<double>  _animation = CurvedAnimation(parent: _controller, curve: Curves.linear);

RotationTransition(
turns: _animation,
child: Icon(Icons.arrow_drop_down_sharp, color: Colors.white, size: 25,)
)

最新更新