AutoRoute v6: Have an initial route other than '/' #1460
-
In version 5 of AutoRoute I had several nested routes. e.g.: routes: <AutoRoute>[
AutoRoute(
page: OnboardingView,
path: '/onboarding',
),
AutoRoute(
page: LoginView,
path: '/login',
initial: true,
),
AutoRoute(
path: '/signup',
page: SignUpView,
),
AutoRoute(
path: '/forgotpassword',
page: ForgotPasswordView,
),
AutoRoute(
path: '/main',
page: MainNavigationView,
children: [
AutoRoute(
path: 'manage',
page: ManageWrapper,
name: 'ManageRouter',
children: [
AutoRoute(
path: 'rootContainers',
page: RootContainersView,
initial: true,
),
AutoRoute(
path: 'containerDetails/:parentContainerUuid',
page: ContainerDetailsView,
),
],
),
],
),
], So in the example, the routes of v5 the login was the initial route but had a path of I used the Android Studio Plugin from AutoRoute, which helped a lot in the migration process, but it didn't work for the use case I was having. The plugin simply replaced Am I missing something or is it no more possible in v6? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
So the solution was in v6 you have to use @override
final List<AutoRoute> routes = [
RedirectRoute(path: '/', redirectTo: '/login'), //Note that '/' needs to be used
AutoRoute(page: LoginViewRoute.page, path: '/login'),
AutoRoute(page: OnboardingViewRoute.page, path: '/onboarding'),
AutoRoute(path: '/signup', page: SignUpViewRoute.page),
AutoRoute(path: '/forgotpassword', page: ForgotPasswordViewRoute.page),
AutoRoute(path: '/main',
page: MainNavigationViewRoute.page,
children: [
AutoRoute(path: 'manage',
page: ManageWrapperRoute.page,
children: [
RedirectRoute(path: '', redirectTo: 'rootContainers'), //Note that '' is being used
AutoRoute(path: 'rootContainers',
page: RootContainersViewRoute.page,
),
AutoRoute(path: 'containerDetails/:parentContainerUuid',
page: ContainerDetailsViewRoute.page),
]),
]; |
Beta Was this translation helpful? Give feedback.
So the solution was in v6 you have to use
RedirectRoute
: