Custom Code: How to Add Page Navigation with Animated Transition

Custom Code

In custom code, to navigate to another page, I'm using something like:

onPressed: () {
   context.pushNamed("wantedPage");
}

This works perfectly, however, i want to animate the page transition on navigation.
I know that FlutterFlow already has that. I tried setting it in FlutterFlow and copied the code, but it doesn't work in the custom widget code for some reason.

onPressed: () async {
    context.pushNamed(
      "wantedPage",
      extra: <String, dynamic>{
        kTransitionInfoKey: TransitionInfo(
          hasTransition: true,
          transitionType: PageTransitionType.topToBottom,
          duration: Duration(milliseconds: 500),
        ),
      },
    );
},

Am I missing something?

What have you tried so far?

-Have searched everywhere can't find answer
-Have copied the code directly from FlutterFlow, and for some reason it doesn't work in the custom code.

Did you check FlutterFlow's Documentation for this topic?
Yes
2