-
Notifications
You must be signed in to change notification settings - Fork 29.7k
Description
Is there an existing issue for this?
- I have searched the existing issues
- I have read the guide to filing a bug
Steps to reproduce
- implement multiple screens (I have more than 50) that will be linked to routes
- configure routes with
path,name, andbuilderparams - run
flutter build apk --obfuscate --split-debug-info=build/app/outputs/split-debug-info
Expected results
App should be working fine as it does in development, all named routes should be linked to its configured paths
Actual results
named routes overwrite each other; since I use --obfuscate when generating the apk, and use the (Screen).toString() as route name. Code obfuscation alters the class names, making 2 routes have the same name but in different case.
I checked the following:
(Login).toString() = uwb
(Register).toString() = Uwb
RouteConfiguration.namedLocation() includes this logic:
...
final String keyName = name.toLowerCase();
assert(_nameToPath.containsKey(keyName), 'unknown route name: $name');
...
RouteConfiguration._cacheNameToPath() includes this logic:
if (route.name != null) {
final String name = route.name!.toLowerCase();
assert(
!_nameToPath.containsKey(name),
'duplication fullpaths for name '
'"$name":${_nameToPath[name]}, $fullPath');
_nameToPath[name] = fullPath;
}
This makes the router navigate to Login screen whether I use context.goNamed((Login).toString()) or context.goNamed((Register).toString())
I could change the way I am naming my routes, but the way I do it makes it easier for development; so if I refactor the screen name, it will be changed in all places, also it doesn't require me to remember every name for every route, or force me to add an extra name to screen mapper.
I couldn't find any use case for using name.toLoweCase() neither in the docs nor in the package code, I think removing toLowerCase() in these 2 places will fix the issue and will not affect the logic anyhow.
Code sample
final router = GoRouter(
routes: [
GoRoute(
path: '/login',
name: (Login).toString(),
builder: (_, __) => Login(),
),
GoRoute(
path: '/register',
name: (Register).toString(),
builder: (_, __) => Register(),
),
...
],
);Screenshots or Video
Screenshots / Video demonstration
[Upload media here]
Logs
Logs
[Paste your logs here]Flutter Doctor output
[✓] Flutter (Channel stable, 3.3.3, on macOS 13.3.1 22E261 darwin-arm, locale en-EG)
[✓] Android toolchain - develop for Android devices (Android SDK version 32.1.0-rc1)
[✓] Xcode - develop for iOS and macOS (Xcode 14.2)
[✓] Chrome - develop for the web
[✓] Android Studio (version 2021.2)
[✓] Connected device (3 available)
[✓] HTTP Host Availability
• No issues found!