admin管理员组

文章数量:1122832

I'm using go_router app navigation both with deep_link package features. By default the app starts at / but if a specific url is tapped on the device (other apps) a specific app screen is opened.

So assuming my domain as example, when I tap on a I'm redirected to the specific route.

final router = GoRouter(
  routes: [
    GoRoute(
      path: '/',
      builder: (_, __) => const MyApp(),
    ),
    GoRoute(
      path: '/api/app/extevents/:id1',
      builder: (_, state) {
        Globals.extEventId = int.tryParse(state.pathParameters['id1'] ?? '');
        Globals.navigatorKey = GlobalKey<NavigatorState>();
        return const MyApp();
      },
    )
  ],
  onException: (context, state, router) => router.go('/'),
);

void main() {
  runApp(
    GlobalLoaderOverlay(
      overlayWidgetBuilder: (progress) => Theme(
        data: RvtTheme.rvtTheme,
        child: const Center(
          child: CircularProgressIndicator(),
        ),
      ),
      child: MaterialApp.router(
        routerConfig: router,

      ),
    ),
  );
}

The problem is that it works only once, if I try to tap the link the second time after you navigate on other app screen, I won't be redirected a new time to the desired route.

Does go router cache this route? How to fix that? I need that the route code is evaluated every time.

I'm using go_router app navigation both with deep_link package features. By default the app starts at / but if a specific url is tapped on the device (other apps) a specific app screen is opened.

So assuming my domain as example.com, when I tap on a https://www.example.com/api/app/extevents/5 I'm redirected to the specific route.

final router = GoRouter(
  routes: [
    GoRoute(
      path: '/',
      builder: (_, __) => const MyApp(),
    ),
    GoRoute(
      path: '/api/app/extevents/:id1',
      builder: (_, state) {
        Globals.extEventId = int.tryParse(state.pathParameters['id1'] ?? '');
        Globals.navigatorKey = GlobalKey<NavigatorState>();
        return const MyApp();
      },
    )
  ],
  onException: (context, state, router) => router.go('/'),
);

void main() {
  runApp(
    GlobalLoaderOverlay(
      overlayWidgetBuilder: (progress) => Theme(
        data: RvtTheme.rvtTheme,
        child: const Center(
          child: CircularProgressIndicator(),
        ),
      ),
      child: MaterialApp.router(
        routerConfig: router,

      ),
    ),
  );
}

The problem is that it works only once, if I try to tap the link the second time after you navigate on other app screen, I won't be redirected a new time to the desired route.

Does go router cache this route? How to fix that? I need that the route code is evaluated every time.

Share Improve this question asked Nov 22, 2024 at 18:13 E.BenedosE.Benedos 1,7571 gold badge17 silver badges45 bronze badges 2
  • Can you provide deep link listener ? – Lightn1ng Commented Nov 25, 2024 at 4:51
  • What do you mean for deep link listener? – E.Benedos Commented Nov 26, 2024 at 7:30
Add a comment  | 

1 Answer 1

Reset to default 0

I'm not sure but you might need key: UniqueKey(), in your GoRoute widgets.

本文标签: fluttergorouter deep link redirect works only onceStack Overflow