如何在flutter中制作动画
How to make animation in flutter
我正在尝试将徽标向右滑动,然后再次从左侧滑动
enter image description here
我试过了,但它弹回了徽标
void initState() {
super.initState();
_controller = AnimationController(
// duration: const Duration(seconds: 90),
vsync: this,
)..repeat(reverse: false);
_offsetAnimation = Tween<Offset>(
begin: Offset.zero,
end: const Offset(7.1, 7.0),
).animate(CurvedAnimation(
parent: _controller,
curve: Curves.easeOutQuint,
));
}
您可以尝试使用以下代码将徽标向右滑动,然后再次从左侧滑动,
void initState() {
super.initState();
_controller = AnimationController(
duration: const Duration(seconds: 2),
vsync: this,
)..repeat(reverse: true);
_offsetAnimation = Tween<Offset>(
begin: Offset(-1.0,0.0), // You can change starting position as per your require.
end: const Offset(1.0, 0.0), // You can change ending position as per your require.
).animate(CurvedAnimation(
parent: _controller,
curve: Curves.linear, // You can change animation curve per your require.
));
}
(参考Curves class选择其他曲线)
我正在尝试将徽标向右滑动,然后再次从左侧滑动 enter image description here 我试过了,但它弹回了徽标
void initState() {
super.initState();
_controller = AnimationController(
// duration: const Duration(seconds: 90),
vsync: this,
)..repeat(reverse: false);
_offsetAnimation = Tween<Offset>(
begin: Offset.zero,
end: const Offset(7.1, 7.0),
).animate(CurvedAnimation(
parent: _controller,
curve: Curves.easeOutQuint,
));
}
您可以尝试使用以下代码将徽标向右滑动,然后再次从左侧滑动,
void initState() {
super.initState();
_controller = AnimationController(
duration: const Duration(seconds: 2),
vsync: this,
)..repeat(reverse: true);
_offsetAnimation = Tween<Offset>(
begin: Offset(-1.0,0.0), // You can change starting position as per your require.
end: const Offset(1.0, 0.0), // You can change ending position as per your require.
).animate(CurvedAnimation(
parent: _controller,
curve: Curves.linear, // You can change animation curve per your require.
));
}
(参考Curves class选择其他曲线)