I just started using auto_route to handle routing in my Flutter app, but now, whenever I save in VSCode and trigger hot reload, it displays the initialRoute again. The expected behavior should be to stay on the current route unless I perform a hot restart. This only happens when I use auto_route; if I don't use this package, I get the correct behavior upon saving. Does anyone know if I can avoid this behavior and still use this package?
I tried to not mark any route as initial but then I just get a blank screen.
You have to ensure that you are not creating an instance of the AppRoute in the build method such as;
final router = AppRouter()This will recreate the router on rebuilds. You can use a service locator like GetIt or Riverpod to pass in a single instance of the router
AppRouter