SchabanBo / qlevar_router

Manage you project Routes. Create nested routes. Simply navigation without context to your pages. Change only one sub widget in your page when navigating to new route.
MIT License
87 stars 22 forks source link

The back button in Browser doesn't work #127

Closed westlinkin closed 1 year ago

westlinkin commented 1 year ago

Chrome: Version 112.0.5615.49 (Official Build) (arm64) qlevar_router: 1.9.0

After use QR.to('/history'), the url becomes xxx.com/history, if click the back button on the appbar, it works fine (url becomes xxx.com/ and the content becomes the home page). But if click the back button of the browser, it breaks. (url becomes xxx.com but the ui is still in history page.)

What went wrong?

Here is the routes:

class AppRoutes {
  final routes = [
    QRoute(
        path: homeScreenPath,
        builder: () => const CupertinoScaffold(body: HomeScreen()),
        middleware: [RedirectLoader()]),
    QRoute(
        path: historyScreenPath,
        builder: () =>
            CupertinoScaffold(body: history_screen.InterviewHistoryScreen()),
        middleware: [
          RedirectLoader(),
          DeferredLoader(history_screen.loadLibrary),
        ]),
  ];
}

The build function is myapp:

Widget build(BuildContext context) {
    QR.settings.enableDebugLog = true;
    QR.settings.autoRestoration = true;
    QR.settings.pagesType = const QCupertinoPage();
    return MaterialApp.router(
        title: '${t.appName} - ${t.slogan}',
        localizationsDelegates: [
          GlobalMaterialLocalizations.delegate,
          GlobalWidgetsLocalizations.delegate,
          GlobalCupertinoLocalizations.delegate,
          CustomFeedbackLocalizationsDelegate(),
        ],
        supportedLocales: AppLocaleUtils.supportedLocales,
        locale: TranslationProvider.of(context).flutterLocale,
        builder: EasyLoading.init(),
        restorationScopeId: 'interviewai',
        routeInformationParser: const QRouteInformationParser(),
        routerDelegate: QRouterDelegate(
          AppRoutes().routes,
          alwaysAddInitPath: true,
          restorationScopeId: 'interviewai',
        ));
  }

the code that goes to history screen:

QR.to(historyScreenPath)

Thanks in advance

westlinkin commented 1 year ago

There is a problem in my laptop. After restarting my laptop, everything is good. Sorry.