Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

simple_annimations 2.2.1 #3

Closed
jgismondi22 opened this issue Aug 7, 2020 · 1 comment
Closed

simple_annimations 2.2.1 #3

jgismondi22 opened this issue Aug 7, 2020 · 1 comment

Comments

@jgismondi22
Copy link

I am having trouble updating the faded animation code due to the MultiTrackTween and controlledAnimation being deprecated. How would the new code appear?

@midas-phoenix
Copy link

@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),
  ),
);

}
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants