-
Notifications
You must be signed in to change notification settings - Fork 3.6k
[go_router] #127016 preserved route name case when caching _nameToPath
#4196
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 6 commits
7ab3bc6
5de2973
a281789
0ad1569
e4e8e67
0e2286d
992bd3c
fd9d8db
1116926
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,66 @@ | ||||||
| // Copyright 2013 The Flutter Authors. All rights reserved. | ||||||
| // Use of this source code is governed by a BSD-style license that can be | ||||||
| // found in the LICENSE file. | ||||||
|
|
||||||
| import 'package:flutter/material.dart'; | ||||||
| import 'package:flutter_test/flutter_test.dart'; | ||||||
| import 'package:go_router/go_router.dart'; | ||||||
|
|
||||||
| void main() { | ||||||
| testWidgets( | ||||||
| 'Route names are case sensitive', | ||||||
| (WidgetTester tester) async { | ||||||
| // config router with 2 routes with the same name but different case (Name, name) | ||||||
| final GlobalKey<NavigatorState> navKey = GlobalKey<NavigatorState>(); | ||||||
| final GoRouter router = GoRouter( | ||||||
| navigatorKey: navKey, | ||||||
| routes: <GoRoute>[ | ||||||
| GoRoute( | ||||||
| path: '/', | ||||||
| name: 'Name', | ||||||
| builder: (_, __) => const ScreenA(), | ||||||
| ), | ||||||
| GoRoute( | ||||||
| path: '/path', | ||||||
| name: 'name', | ||||||
| builder: (_, __) => const ScreenB(), | ||||||
| ), | ||||||
| ], | ||||||
| ); | ||||||
|
|
||||||
| // run MaterialApp, initial screen path is '/' -> ScreenA | ||||||
| await tester.pumpWidget( | ||||||
| MaterialApp.router( | ||||||
| routerConfig: router, | ||||||
| title: 'GoRouter Testcase', | ||||||
| ), | ||||||
| ); | ||||||
|
|
||||||
| // go to ScreenB | ||||||
| navKey.currentContext!.goNamed('name'); | ||||||
| assert(GoRouter.of(navKey.currentContext!).location == '/path'); | ||||||
|
||||||
| assert(GoRouter.of(navKey.currentContext!).location == '/path'); | |
| expect(find.byType(ScreenB), findsOneWidget); |
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| navKey.currentContext!.goNamed('Name'); | |
| router.goNamed('Name'); |
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
expect(find.byType(ScreenA), findsOneWidget);
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suggestions are applied, thanks ✌️
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.