simple_annimations 2.2.1
jgismondi22 opened this issue · comments
Jeremy Gismondi commented
I am having trouble updating the faded animation code due to the MultiTrackTween and controlledAnimation being deprecated. How would the new code appear?
Ibrahim Olayokun commented
@jgismondi22
import 'package:flutter/material.dart';
import 'package:simple_animations/simple_animations.dart';
enum AniProps { opacity, translateY }
class FadeAnimation extends StatelessWidget {
final double delay;
final Widget child;
FadeAnimation(this.delay, this.child);
@OverRide
Widget build(BuildContext context) {
final tween = MultiTween<AniProps>()
..add(AniProps.opacity, Tween(begin: 0.0, end: 1.0),
Duration(milliseconds: 500))
..add(AniProps.translateY, Tween(begin: -130.0, end: 0.0),
Duration(milliseconds: 500), Curves.easeOut);
return CustomAnimation<MultiTweenValues<AniProps>>(
delay: Duration(milliseconds: (500 * delay).round()),
duration: tween.duration,
tween: tween,
child: child,
builder: (context, child, animation) => Opacity(
opacity: animation.get(AniProps.opacity),
child: Transform.translate(
offset: Offset(0, animation.get(AniProps.translateY)),
child: child),
),
);
}
}