I use a pageTransitionTheme on the main.dart file and I use a Hero animation too on a page. The problem is when I click on the picture the Hero animation and the CupertinoPageTransition are work at the same time. Is there any solution to disable CuperinoPageTransition in this situation without removing it from main.dart file?

Thanks!

main.dart

...
pageTransitionsTheme: PageTransitionsTheme(builders: {
        TargetPlatform.iOS: CupertinoPageTransitionsBuilder(),
        TargetPlatform.android: CupertinoPageTransitionsBuilder(),
      }),

...

detail_screen.dart

...
ImageSlideshow(
  width: double.infinity,
  height: 200,
  initialPage: 0,
  indicatorColor: cSecondaryColor,
  indicatorBackgroundColor: Colors.grey,
  children: [
     for (var image in images!['imageUrls'])
       InkWell(
          onTap: () {
            Navigator.of(context).pushNamed(
              ImageViewScreen.routeName,
              arguments: image,
            );
          },
          child: Hero(
            tag: '$image',
            child: Image.network(
               image.toString(),
               fit: BoxFit.fitHeight,
           ),
         ),
       ),
      ],
    ),
....


Solution 1: gtxtreme

Remove the pageTransitionsTheme argument

You can use onGenerateRoute to customise the behaviour when a new Route is generated like so

onGenerateRoute: (settings) {
  if (settings.name == "/someRoute") {
// See other customisable parameters of this class like transitionBuilder
    return PageRouteBuilder(
      settings: settings, 
      pageBuilder: (_, __, ___) => SomePage(),
      transitionDuration: Duration(seconds: 0)
    );
  }
  // Unknown route
  //You can use any route that you like here or make a new route by inheriting the other routes

  return CupertinoPageRoute(builder: (_) => UnknownPage());
},

The CupertinoPageRoute will use the CupertinoPageTransitionsBuilder transitionbuilder class by default