Skip to content

Instantly share code, notes, and snippets.

@naxmefy
Created December 29, 2019 17:27
Show Gist options
  • Save naxmefy/05012f3d14785774f95959c2525341f1 to your computer and use it in GitHub Desktop.
Save naxmefy/05012f3d14785774f95959c2525341f1 to your computer and use it in GitHub Desktop.
import 'package:flutter/material.dart';
import 'package:simple_animations/simple_animations/controlled_animation.dart';
import 'package:simple_animations/simple_animations/multi_track_tween.dart';
class FadeAnimation extends StatelessWidget {
final double delay;
final Widget child;
const FadeAnimation(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("translateY").add(
Duration(milliseconds: 500), Tween(begin: -30.0, end: 0.0),
curve: Curves.easeOut)
]);
return ControlledAnimation(
child: child,
delay: Duration(milliseconds: (500 * delay).round()),
duration: tween.duration,
tween: tween,
builderWithChild: (context, child, animation) => Opacity(
opacity: animation["opacity"],
child: Transform.translate(
offset: Offset(0, animation["translateY"]),
child: child,
),
),
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment