animated<T> function

Widget animated<T>(
  1. AnimationType animationType, {
  2. required String name,
  3. bool reversed = false,
  4. required Animation<double> animation,
  5. required Widget child,
})

Implementation

Widget animated<T>(
  AnimationType animationType, {
  required String name,
  bool reversed = false,
  required Animation<double> animation,
  required Widget child,
}) {
  switch (animationType) {
    case AnimationType.size:
      return SizeTransition(
          key: Key("size-$name"),
          sizeFactor: animation,
          axis: Axis.vertical,
          axisAlignment: 0.0,
          child: child);
    case AnimationType.fade:
      return FadeTransition(
          key: Key("fade-$name"), opacity: animation, child: child);
    case AnimationType.slide:
      return SizeTransition(
        key: Key("size-$name"),
        sizeFactor: CurvedAnimation(
            curve: Interval(
              0.0,
              0.3,
              curve: Curves.decelerate,
            ),
            parent: animation),
        axis: Axis.vertical,
        axisAlignment: 0.0,
        child: SlideTransition(
          child: child,
          key: Key("size-slide-$name"),
          position: Tween<Offset>(
            begin: const Offset(-1, 0),
            end: Offset.zero,
          ).animate(animation),
        ),
      );

    default:
      return child;
  }
}