Что может быть лучше для реализации той же логики c в приведенном ниже коде?
Я пытался использовать TweenSequence
, но я не могу управлять свойствами интервалов различных виджетов, как в коде ниже.
AnimationController _opacityController;
AnimationController _scaleController;
Animation<double> _scaleAnim;
Animation<double> _topOpacityAnim;
Animation<double> _opacityAnim;
Animation<double> _delayedOpacityAnim;
Animation<double> _muchdelayedOpacityAnim;
@override
void initState() {
super.initState();
_opacityController =
AnimationController(vsync: this, duration: Duration(milliseconds: 4000))
..addListener(() => setState(() {}));
_scaleController =
AnimationController(vsync: this, duration: Duration(milliseconds: 2000))
..addListener(() => setState(() {}))
..addStatusListener((status) {
if (_scaleController.status == AnimationStatus.completed)
_scaleController.reverse();
});
_scaleAnim = Tween<double>(begin: 1, end: 1.2).animate(CurvedAnimation(
curve: Interval(
0.2,
1,
),
parent: _scaleController));
_topOpacityAnim = Tween<double>(begin: 0, end: 1).animate(
CurvedAnimation(parent: _opacityController, curve: Interval(0, 0.3)));
_delayedOpacityAnim = Tween<double>(begin: 0, end: 1.0).animate(
CurvedAnimation(
parent: _opacityController,
curve: Interval(0.6, 0.8, curve: Curves.fastOutSlowIn)));
_muchdelayedOpacityAnim = Tween<double>(begin: 0, end: 1.0).animate(
CurvedAnimation(
parent: _opacityController,
curve: Interval(0.8, 1.0, curve: Curves.fastOutSlowIn)));
_opacityAnim = Tween<double>(begin: 0, end: 1).animate(
CurvedAnimation(parent: _opacityController, curve: Interval(0.3, 0.6)));
_scaleController.forward();
_opacityController.forward();
}