[Solved] FadeTransition with Flutter Named Routes

Kaya Ryuuna Asks: FadeTransition with Flutter Named Routes
I have a flutter app, with a few pages, and I’m implementing named routes. But I want the navigation between screens to be done with FadeTransition, just so it’s a smoother transition.

How can I make navigation with named routes have an animation, when transitioning between screens? I did a lot of research, but I couldn’t find tips with named routes.

This is the method I use to do the Navigation, it looks for the class name.

Code:
void goToView(context, view) {
    Navigator.of(context).push(
        PageRouteBuilder(
          opaque: true,
          transitionDuration: const Duration(milliseconds: 800),
          pageBuilder: (BuildContext context, _, __) {
            return view;
          },
          transitionsBuilder:
              (_, Animation<double> animation, __, Widget child) {
            return SlideTransition(
              position: Tween<Offset>(
                begin: Offset(0.0, 1.0),
                end: Offset(0.0, 0.0),
              ).animate(
                CurvedAnimation(
                  parent: animation,
                  curve: Interval(
                    0.00,
                    0.50,
                    curve: Curves.linear,
                  ),
                ),
              ),
              child: SlideTransition(
                position: Tween<Offset>(
                  begin: Offset(0.0, 1.0),
                  end: Offset(0.0, 0.0),
                ).animate(
                  CurvedAnimation(
                    parent: animation,
                    curve: Interval(
                      0.00,
                      0.50,
                      curve: Curves.linear,
                    ),
                  ),
                ),
                child: child,
              ),
            );
          },
        ));
  }

Ten-tools.com may not be responsible for the answers or solutions given to any question asked by the users. All Answers or responses are user generated answers and we do not have proof of its validity or correctness. Please vote for the answer that helped you in order to help others find out which is the most helpful answer. Questions labeled as solved may be solved or may not be solved depending on the type of question and the date posted for some posts may be scheduled to be deleted periodically. Do not hesitate to share your response here to help other visitors like you. Thank you, Ten-tools.