0

i am using auto_route plugin for my flutter web project. for now, I have just implemented 3 pages for the navigation demo.

  1. first page
  2. second page
  3. third page

and this is my routing setup

@MaterialAutoRouter(
  replaceInRouteName: 'Route',
  routes: <AutoRoute>[
    AutoRoute(page: FirstPage, initial: true),
    AutoRoute(page: SecondPage),
    AutoRoute(page: ThirdPage),
  ],
)
class $AppRouter {}

i am passing argument from first page to second page as

context.pushRoute(
        SecondPageRoute(value: "This is passed value"),
);

and then navigating from second page to third page. and from the third page when I am pressing the back button from the chrome browser, it throws an error as

SecondPageRouteArgs can not be null because it has a required parameter

because while navigating back, the required argument on the second page is not getting(obviously it will not), so I don't know how to solve this.

1
  • Probably you can use OnWillPopScope to handle the back button behavior. I am not familiar with auto router, so I just leave you this tip without real deep knowledge. I know it works using the flutter RouterDelegate
    – 0ver0n
    Nov 7, 2022 at 16:19

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.