-
Notifications
You must be signed in to change notification settings - Fork 29.7k
Description
Steps to reproduce
Create a GoRoute starting with '/'. That compiles just fine. Now place that route as a child of another route => assertion error.
Expected results
Either all routes should require / or none should. As it is currently, it violates an OOP principles where an object must be in a valid state after construction.
Concretely I cannot create an AccountRoute for example that is not aware where it is going to be placed. Will it be a child of another route or will it be a "root" route ? None of its business. You also can't move route around without modifying their path.
If internally go_router requires some special rules it should deal with it internally and not reflected those in the public API.
Actual results
assertion throws: sub-route path may not start or end with "/": $route'
Code sample
GoRouter(
routes: [
GoRoute(
path: '/a',
builder: (context, state) => Text(''),
routes: [
GoRoute(
path: '/b',
builder: (context, state) => Text(''),
),
]
),
]
);
Screenshots or Video
No response
Logs
No response
Flutter Doctor output
Doctor summary (to see all details, run flutter doctor -v):
[√] Flutter (Channel stable, 3.19.2, on Microsoft Windows [Version 10.0.22631.3296], locale en-BE)
[√] Windows Version (Installed version of Windows is version 10 or higher)
[√] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
[√] Chrome - develop for the web
[√] Visual Studio - develop Windows apps (Visual Studio Build Tools 2019 16.11.32)
[√] Android Studio (version 2023.1)
[√] VS Code (version 1.87.2)
[√] Connected device (3 available)
[√] Network resources
• No issues found!