Created
April 11, 2019 16:09
-
-
Save felixblaschke/f4aa50daa3e3790faf97d7d4ac54d0cd to your computer and use it in GitHub Desktop.
FadeIn Widget
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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