I want to reuse routes for different branches in tabs.
I have a tabs shell route
@TypedStatefulShellRoute(
branches: >[
homeBranch,
menuBranch,
],
)
const homeBranch = TypedStatefulShellBranch(
routes: >[
TypedGoRoute(
path: '/home',
routes: [
],
),
],
);
class HomeTabData extends StatefulShellBranchData {
const HomeTabData();
}
class HomeTabRoute extends GoRouteData {
const HomeTabRoute();
@override
Widget build(final BuildContext context, final GoRouterState state) => const HomePage();
}
const menuBranch = TypedStatefulShellBranch(
routes: >[
TypedGoRoute(path: '/menu'),
],
);
class MenuTabData extends StatefulShellBranchData {
const MenuTabData();
}
class MenuTabRoute extends GoRouteData {
const MenuTabRoute();
@override
Widget build(final BuildContext context, final GoRouterState state) => const MenuPage();
}
And also a web screen route.
@TypedGoRoute(path: '/url')
class WebScreenRoute extends GoRouteData {
final String? url;
final int? articleId;
WebScreenRoute({this.url, this.articleId});
static final GlobalKey $parentNavigatorKey = _rootNavigatorKey;
@override
Widget build(final BuildContext context, final GoRouterState state) {
if (url != null) {
return WebPage(
params: WebScreenParamsUrl(url!),
);
} else if (articleId != null) {
return WebPage(
params: WebScreenParamsArticle(articleId!),
);
}
throw UnimplementedError();
}
}
All I want is to have an ability to use /home/url and /menu/url paths at the same time for all possible tabs. Is that event possible with the current state of go_router and go_router_builder? I haven't found a way to set same WebScreenRoute as subroutes for the branches, since builder starts generating WebScreenRoute's classes with the same name but different internal paths. I understand that /url comes from the root path, but TypedGoRoute requires paths to start with a /, and I'm stuck. I want to implement this using go_router and don't want to write a hacky solution on top of the navigator 2.0.