fadeIn function

Widget fadeIn(
  1. dynamic child,
  2. {double offsetX = 0,
  3. double offsetY = 0,
  4. int duration = 800,
  5. int delay = 0,
  6. dynamic curve = Curves.easeOut}
)

Implementation

Widget fadeIn(child,
    {double offsetX = 0,
    double offsetY = 0,
    int duration = 800,
    int delay = 0,
    curve = Curves.easeOut}) {
  return Animo((defineAnimation) {
    AAnimation anim =
        defineAnimation(duration: Duration(milliseconds: duration + delay));
    double startAt = delay / (duration + delay);
    ATween opacity = ATween(
        begin: 0,
        end: 1,
        interval: Interval(startAt, 1, curve: Curves.easeOut));
    ATween positionX = ATween(
        begin: offsetX, end: 0, interval: Interval(startAt, 1, curve: curve));
    ATween positionY = ATween(
        begin: offsetY, end: 0, interval: Interval(startAt, 1, curve: curve));

    anim.attach([opacity, positionX, positionY]);
    anim.controller.forward();

    return () {
      return withOpacity(
          withTranslate(child, x: positionX.value, y: positionY.value),
          value: opacity.value);
    };
  });
}