@@ -20,6 +20,8 @@ import 'state.dart';
20
20
typedef GoRouterRedirect = FutureOr <String ?> Function (
21
21
BuildContext context, GoRouterState state);
22
22
23
+ typedef _NamedPath = ({String path, bool caseSensitive});
24
+
23
25
/// The route configuration for GoRouter configured by the app.
24
26
class RouteConfiguration {
25
27
/// Constructs a [RouteConfiguration] .
@@ -246,7 +248,7 @@ class RouteConfiguration {
246
248
/// example.
247
249
final Codec <Object ?, Object ?>? extraCodec;
248
250
249
- final Map <String , String > _nameToPath = < String , String > {};
251
+ final Map <String , _NamedPath > _nameToPath = < String , _NamedPath > {};
250
252
251
253
/// Looks up the url location by a [GoRoute] 's name.
252
254
String namedLocation (
@@ -264,11 +266,11 @@ class RouteConfiguration {
264
266
return true ;
265
267
}());
266
268
assert (_nameToPath.containsKey (name), 'unknown route name: $name ' );
267
- final String path = _nameToPath[name]! ;
269
+ final _NamedPath path = _nameToPath[name]! ;
268
270
assert (() {
269
271
// Check that all required params are present
270
272
final List <String > paramNames = < String > [];
271
- patternToRegExp (path, paramNames);
273
+ patternToRegExp (path.path , paramNames, caseSensitive : path.caseSensitive );
272
274
for (final String paramName in paramNames) {
273
275
assert (pathParameters.containsKey (paramName),
274
276
'missing param "$paramName " for $path ' );
@@ -284,7 +286,10 @@ class RouteConfiguration {
284
286
for (final MapEntry <String , String > param in pathParameters.entries)
285
287
param.key: Uri .encodeComponent (param.value)
286
288
};
287
- final String location = patternToPath (path, encodedParams);
289
+ final String location = patternToPath (
290
+ path.path,
291
+ encodedParams,
292
+ );
288
293
return Uri (
289
294
path: location,
290
295
queryParameters: queryParameters.isEmpty ? null : queryParameters,
@@ -528,8 +533,9 @@ class RouteConfiguration {
528
533
529
534
if (_nameToPath.isNotEmpty) {
530
535
sb.writeln ('known full paths for route names:' );
531
- for (final MapEntry <String , String > e in _nameToPath.entries) {
532
- sb.writeln (' ${e .key } => ${e .value }' );
536
+ for (final MapEntry <String , _NamedPath > e in _nameToPath.entries) {
537
+ sb.writeln (
538
+ ' ${e .key } => ${e .value .path }${e .value .caseSensitive ? '' : ' (case-insensitive)' }' );
533
539
}
534
540
}
535
541
@@ -594,8 +600,9 @@ class RouteConfiguration {
594
600
assert (
595
601
! _nameToPath.containsKey (name),
596
602
'duplication fullpaths for name '
597
- '"$name ":${_nameToPath [name ]}, $fullPath ' );
598
- _nameToPath[name] = fullPath;
603
+ '"$name ":${_nameToPath [name ]!.path }, $fullPath ' );
604
+ _nameToPath[name] =
605
+ (path: fullPath, caseSensitive: route.caseSensitive);
599
606
}
600
607
601
608
if (route.routes.isNotEmpty) {
0 commit comments