【Flutter】画面遷移時に下から上に出るアニメーションサンプル

Navigator.push(
  context,
  PageRouteBuilder(
    pageBuilder: (context, animation, secondaryAnimation) {
      return const MyPage(); // 遷移するページ
    },
    transitionsBuilder:
        (context, animation, secondaryAnimation, child) {
      const Offset begin = Offset(0.0, 1.0);
      const Offset end = Offset.zero;
      final Animatable<Offset> tween = Tween(begin: begin, end: end)
          .chain(CurveTween(curve: Curves.easeInOut));
      final Animation<Offset> position = animation.drive(tween);
      return SlideTransition(
        position: position,
        child: child,
      );
    },
  ),
);

Flutter開発で知らないと損すること Flutter開発で知らないと損すること

コメントを残す

メールアドレスが公開されることはありません。 * が付いている欄は必須項目です