Home > Software design >  Is there any way to prevent Hero transition on specific routes?
Is there any way to prevent Hero transition on specific routes?

Time:11-27

we give same tags to Hero widgets and watch their transition between route transitions. I want to prevent specific Hero tag between specific routes. Is there any solution for this? Can I say don't animate between this specific routes like this?

Example:

HeroControllerScope(
  controller: HeroController(
    excludedRoutes: [Routes.BOOKING_SUMMARY, Routes.SUPER_PRODUCTS],
  ),
  //lorem ipsum image
  child: Hero(
    child: Image.network('https://i.picsum.photos/id/184/200/300.jpg'),
  ),
)

CodePudding user response:

use class HeroMode

child : HeroMode(
        enabled: _routes == Routes.BOOKING_SUMMARY || _routes == Routes.SUPER_PRODUCTS ? false:true, 
        child:Hero(
              tag: "my-image",
              child(Image.network(uri),
  • Related