Milad-Akarie / auto_route_library

Flutter route generator
MIT License
1.59k stars 405 forks source link

Issue with Nested Navigation in auto_route Package #2034

Open sreekuttywork007 opened 3 months ago

sreekuttywork007 commented 3 months ago

I am currently using the auto_route package (version ^9.2.0) in my Flutter project, and I am encountering a problem with nested navigation. Specifically, I am having issues with the replace and replaceAll methods in the context of child routers.

Here’s a brief overview of the setup and issue:

import 'package:auto_route/auto_route.dart';

@MaterialAutoRouter(
  replaceInRouteName: 'Page,Route',
  routes: <AutoRoute>[
    AutoRoute(page: GrandparentPage, initial: true, children: [
      AutoRoute(page: ParentPage, children: [
        AutoRoute(page: ChildPage1),
        AutoRoute(page: ChildPage2),
      ]),
      AutoRoute(page: TargetPage),
    ]),
  ],
)

class $AppRouter {}

Issue: After completing the flow through all the child routes, I want to navigate to the TargetPage and prevent navigation back to the previous screens when pressing the back button. However, the replace and replaceAll functions do not seem to work as expected in this scenario. I have also tried using other functions such as popUntil(), as mentioned in the package documentation, but this did not resolve the issue. I am using GetIt it for dependency injection, and the problem persists despite these attempts.

NijatTagizada commented 2 months ago

Same issue. replaceAll not working