Flutter Web - Go Router Navigation Change Web URL based on bottom tab selection

Viewed 49

I was trying to implement a bottom-tab navigation with 3 tabs in my home screen for my flutter website project. Currently I'm using go_router package for flutter web routing.

Following is my code for web app navigation, What I want to achieve is ontap of particular bottom tab 1 tap. I want to change the url to something like <Web_URL>/#Tab1.

But, I couldn't found anything useful. Can anyone please help?

static final List<GoRoute> _appRoutes = [
    GoRoute(
        path: AppRouter.pathLogin,
        builder: (BuildContext context, GoRouterState state) =>
            const LoginScreen()),
    GoRoute(
      path: AppRouter.pathHome,
      builder: (BuildContext context, GoRouterState state) =>
          const HomeScreen(),
      routes: [
        GoRoute(
            path: AppRouter.pathCreateContact,
            builder: (BuildContext context, GoRouterState state) =>
                const CreateContactScreen()),
      ],
    ),
  ];

  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    return MaterialApp.router(
        title: 'Follow-Up',
        debugShowCheckedModeBanner: false,
        routeInformationParser: _router.routeInformationParser,
        routeInformationProvider: _router.routeInformationProvider,
        routerDelegate: _router.routerDelegate);
  }

  final GoRouter _router = GoRouter(
      routes: _appRoutes,
      urlPathStrategy: UrlPathStrategy.path,
      initialLocation: FirebaseAuth.instance.currentUser != null
          ? AppRouter.pathHome
          : AppRouter.pathLogin);
0 Answers
Related