Skip to content

Instantly share code, notes, and snippets.

@felixblaschke
Created April 11, 2019 16:09
Show Gist options
  • Save felixblaschke/f4aa50daa3e3790faf97d7d4ac54d0cd to your computer and use it in GitHub Desktop.
Save felixblaschke/f4aa50daa3e3790faf97d7d4ac54d0cd to your computer and use it in GitHub Desktop.
FadeIn Widget
class FadeIn extends StatelessWidget {
final double delay;
final Widget child;
FadeIn(this.delay, this.child);
@override
Widget build(BuildContext context) {
final tween = MultiTrackTween([
Track("opacity")
.add(Duration(milliseconds: 500), Tween(begin: 0.0, end: 1.0)),
Track("translateX").add(
Duration(milliseconds: 500), Tween(begin: 130.0, end: 0.0),
curve: Curves.easeOut)
]);
return ControlledAnimation(
delay: Duration(milliseconds: (300 * delay).round()),
duration: tween.duration,
tween: tween,
child: child,
builderWithChild: (context, child, animation) => Opacity(
opacity: animation["opacity"],
child: Transform.translate(
offset: Offset(animation["translateX"], 0), child: child),
),
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment