Repository navigation
Expand file tree
/
Copy pathroute_data.dart
More file actions
682 lines (596 loc) · 23.2 KB
/
Copy pathroute_data.dart
File metadata and controls
682 lines (596 loc) · 23.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
// Copyright 2013 The Flutter Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import 'dart:async';
import 'package:flutter/widgets.dart';
import 'package:meta/meta.dart';
import 'package:meta/meta_meta.dart';
import 'configuration.dart';
import 'route.dart';
import 'state.dart';
/// Baseclass for supporting
/// [Type-safe routing](https://pub.dev/documentation/go_router/latest/topics/Type-safe%20routes-topic.html).
abstract class RouteData {
/// Allows subclasses to have `const` constructors.
const RouteData();
}
/// A base class for [GoRouteData] and [RelativeGoRouteData] that provides
/// common functionality for type-safe routing.
abstract class _GoRouteDataBase extends RouteData {
const _GoRouteDataBase();
/// Creates the [Widget] for `this` route.
///
/// Subclasses must override one of [build], [buildPage], or
/// [redirect].
///
/// Corresponds to [GoRoute.builder].
Widget build(BuildContext context, GoRouterState state) =>
throw UnimplementedError('One of `build` or `buildPage` must be implemented.');
/// A page builder for this route.
///
/// Subclasses can override this function to provide a custom [Page].
///
/// Subclasses must override one of [build], [buildPage] or
/// [redirect].
///
/// Corresponds to [GoRoute.pageBuilder].
///
/// By default, returns a [Page] instance that is ignored, causing a default
/// [Page] implementation to be used with the results of [build].
Page<void> buildPage(BuildContext context, GoRouterState state) => const NoOpPage();
/// An optional redirect function for this route.
///
/// Subclasses must override one of [build], [buildPage], or
/// [redirect].
///
/// Corresponds to [GoRoute.redirect].
FutureOr<String?> redirect(BuildContext context, GoRouterState state) => null;
/// Called when this route is removed from GoRouter's route history.
///
/// Corresponds to [GoRoute.onExit].
FutureOr<bool> onExit(BuildContext context, GoRouterState state) => true;
/// The error thrown when a user-facing method is not implemented by the
/// generated code.
static UnimplementedError get shouldBeGeneratedError => UnimplementedError(
'Should be generated using [Type-safe routing](https://pub.dev/documentation/go_router/latest/topics/Type-safe%20routes-topic.html).',
);
/// Used to cache [_GoRouteDataBase] that corresponds to a given [GoRouterState]
/// to minimize the number of times it has to be deserialized.
static final Expando<_GoRouteDataBase> stateObjectExpando = Expando<_GoRouteDataBase>(
'GoRouteState to _GoRouteDataBase expando',
);
}
/// Helper to build a location string from a path and query parameters.
String _buildLocation(String path, {Map<String, dynamic>? queryParams}) => Uri.parse(path)
.replace(
queryParameters:
// Avoid `?` in generated location if `queryParams` is empty
queryParams?.isNotEmpty ?? false ? queryParams : null,
)
.toString();
/// Holds the parameters for constructing a [GoRoute].
class _GoRouteParameters {
const _GoRouteParameters({
required this.builder,
required this.pageBuilder,
required this.redirect,
this.onExit,
});
final GoRouterWidgetBuilder builder;
final GoRouterPageBuilder pageBuilder;
final GoRouterRedirect redirect;
final ExitCallback? onExit;
}
/// Helper to create [GoRoute] parameters from a factory function and an Expando.
///
/// When [hasOverriddenOnExit] is null, treat it the same as true for backward compatibility.
_GoRouteParameters _createGoRouteParameters<T extends _GoRouteDataBase>({
required T Function(GoRouterState) factory,
required Expando<_GoRouteDataBase> expando,
bool? hasOverriddenOnExit,
}) {
T factoryImpl(GoRouterState state) {
final Object? extra = state.extra;
// If the "extra" value is of type `T` then we know it's the source
// instance, so it doesn't need to be recreated.
if (extra is T) {
return extra;
}
return (expando[state] ??= factory(state)) as T;
}
return _GoRouteParameters(
builder: (BuildContext context, GoRouterState state) =>
factoryImpl(state).build(context, state),
pageBuilder: (BuildContext context, GoRouterState state) =>
factoryImpl(state).buildPage(context, state),
redirect: (BuildContext context, GoRouterState state) =>
factoryImpl(state).redirect(context, state),
onExit: hasOverriddenOnExit == null || hasOverriddenOnExit
? (BuildContext context, GoRouterState state) => factoryImpl(state).onExit(context, state)
: null,
);
}
/// A class to represent a [GoRoute] in
/// [Type-safe routing](https://pub.dev/documentation/go_router/latest/topics/Type-safe%20routes-topic.html).
///
/// Subclasses must override one of [build], [buildPage], or
/// [redirect].
/// {@category Type-safe routes}
abstract class GoRouteData extends _GoRouteDataBase {
/// Allows subclasses to have `const` constructors.
///
/// [GoRouteData] is abstract and cannot be instantiated directly.
const GoRouteData();
/// A helper function used by generated code.
///
/// Should not be used directly.
static String $location(String path, {Map<String, dynamic>? queryParams}) =>
_buildLocation(path, queryParams: queryParams);
/// A helper function used by generated code.
///
/// Should not be used directly.
static GoRoute $route<T extends GoRouteData>({
required String path,
String? name,
bool caseSensitive = true,
required T Function(GoRouterState) factory,
GlobalKey<NavigatorState>? parentNavigatorKey,
List<RouteBase> routes = const <RouteBase>[],
bool? hasOverriddenOnExit,
}) {
final _GoRouteParameters params = _createGoRouteParameters<T>(
factory: factory,
expando: _GoRouteDataBase.stateObjectExpando,
hasOverriddenOnExit: hasOverriddenOnExit,
);
return GoRoute(
path: path,
name: name,
caseSensitive: caseSensitive,
builder: params.builder,
pageBuilder: params.pageBuilder,
redirect: params.redirect,
routes: routes,
parentNavigatorKey: parentNavigatorKey,
onExit: params.onExit,
);
}
/// The location of this route, e.g. /family/f2/person/p1
String get location => throw _GoRouteDataBase.shouldBeGeneratedError;
/// Navigate to the route.
void go(BuildContext context) => throw _GoRouteDataBase.shouldBeGeneratedError;
/// Push the route onto the page stack.
Future<T?> push<T>(BuildContext context) => throw _GoRouteDataBase.shouldBeGeneratedError;
/// Replaces the top-most page of the page stack with the route.
void pushReplacement(BuildContext context) => throw _GoRouteDataBase.shouldBeGeneratedError;
/// Replaces the top-most page of the page stack with the route but treats
/// it as the same page.
///
/// The page key will be reused. This will preserve the state and not run any
/// page animation.
///
void replace(BuildContext context) => throw _GoRouteDataBase.shouldBeGeneratedError;
}
/// A class to represent a relative [GoRoute] in
/// [Type-safe routing](https://pub.dev/documentation/go_router/latest/topics/Type-safe%20routes-topic.html).
///
/// Subclasses must override one of [build], [buildPage], or
/// [redirect].
/// {@category Type-safe routes}
abstract class RelativeGoRouteData extends _GoRouteDataBase {
/// Allows subclasses to have `const` constructors.
///
/// [RelativeGoRouteData] is abstract and cannot be instantiated directly.
const RelativeGoRouteData();
/// A helper function used by generated code.
///
/// Should not be used directly.
static String $location(String path, {Map<String, dynamic>? queryParams}) =>
_buildLocation(path, queryParams: queryParams);
/// A helper function used by generated code.
///
/// Should not be used directly.
static GoRoute $route<T extends RelativeGoRouteData>({
required String path,
bool caseSensitive = true,
required T Function(GoRouterState) factory,
GlobalKey<NavigatorState>? parentNavigatorKey,
List<RouteBase> routes = const <RouteBase>[],
bool? hasOverriddenOnExit,
}) {
final _GoRouteParameters params = _createGoRouteParameters<T>(
factory: factory,
expando: _GoRouteDataBase.stateObjectExpando,
hasOverriddenOnExit: hasOverriddenOnExit,
);
return GoRoute(
path: path,
caseSensitive: caseSensitive,
builder: params.builder,
pageBuilder: params.pageBuilder,
redirect: params.redirect,
routes: routes,
parentNavigatorKey: parentNavigatorKey,
onExit: params.onExit,
);
}
/// The sub-location of this route, e.g. person/p1
String get subLocation => throw _GoRouteDataBase.shouldBeGeneratedError;
/// The relative location of this route, e.g. ./person/p1
String get relativeLocation => throw _GoRouteDataBase.shouldBeGeneratedError;
/// Navigate to the route.
void goRelative(BuildContext context) => throw _GoRouteDataBase.shouldBeGeneratedError;
/// Push the route onto the page stack.
Future<T?> pushRelative<T>(BuildContext context) => throw _GoRouteDataBase.shouldBeGeneratedError;
/// Replaces the top-most page of the page stack with the route.
void pushReplacementRelative(BuildContext context) =>
throw _GoRouteDataBase.shouldBeGeneratedError;
/// Replaces the top-most page of the page stack with the route but treats
/// it as the same page.
///
/// The page key will be reused. This will preserve the state and not run any
/// page animation.
///
void replaceRelative(BuildContext context) => throw _GoRouteDataBase.shouldBeGeneratedError;
}
/// A class to represent a [ShellRoute] in
/// [Type-safe routing](https://pub.dev/documentation/go_router/latest/topics/Type-safe%20routes-topic.html).
abstract class ShellRouteData extends RouteData {
/// Allows subclasses to have `const` constructors.
///
/// [ShellRouteData] is abstract and cannot be instantiated directly.
const ShellRouteData();
/// [pageBuilder] is used to build the page
Page<void> pageBuilder(BuildContext context, GoRouterState state, Widget navigator) =>
const NoOpPage();
/// [builder] is used to build the widget
Widget builder(BuildContext context, GoRouterState state, Widget navigator) =>
throw UnimplementedError('One of `builder` or `pageBuilder` must be implemented.');
/// An optional redirect function for this route.
///
/// Subclasses must override one of [build], [buildPage], or
/// [redirect].
///
/// Corresponds to [GoRoute.redirect].
FutureOr<String?> redirect(BuildContext context, GoRouterState state) => null;
/// A helper function used by generated code.
///
/// Should not be used directly.
static ShellRoute $route<T extends ShellRouteData>({
required T Function(GoRouterState) factory,
GlobalKey<NavigatorState>? navigatorKey,
GlobalKey<NavigatorState>? parentNavigatorKey,
List<RouteBase> routes = const <RouteBase>[],
bool notifyRootObserver = true,
List<NavigatorObserver>? observers,
String? restorationScopeId,
Clip clipBehavior = Clip.hardEdge,
}) {
T factoryImpl(GoRouterState state) {
return (_stateObjectExpando[state] ??= factory(state)) as T;
}
FutureOr<String?> redirect(BuildContext context, GoRouterState state) =>
factoryImpl(state).redirect(context, state);
Widget builder(BuildContext context, GoRouterState state, Widget navigator) =>
factoryImpl(state).builder(context, state, navigator);
Page<void> pageBuilder(BuildContext context, GoRouterState state, Widget navigator) =>
factoryImpl(state).pageBuilder(context, state, navigator);
return ShellRoute(
builder: builder,
pageBuilder: pageBuilder,
parentNavigatorKey: parentNavigatorKey,
routes: routes,
navigatorKey: navigatorKey,
notifyRootObserver: notifyRootObserver,
observers: observers,
restorationScopeId: restorationScopeId,
redirect: redirect,
clipBehavior: clipBehavior,
);
}
/// Used to cache [ShellRouteData] that corresponds to a given [GoRouterState]
/// to minimize the number of times it has to be deserialized.
static final Expando<ShellRouteData> _stateObjectExpando = Expando<ShellRouteData>(
'GoRouteState to ShellRouteData expando',
);
}
/// Base class for supporting
/// [StatefulShellRoute](https://pub.dev/documentation/go_router/latest/go_router/StatefulShellRoute-class.html)
abstract class StatefulShellRouteData extends RouteData {
/// Default const constructor
const StatefulShellRouteData();
/// An optional redirect function for this route.
///
/// Subclasses must override one of [build], [buildPage], or
/// [redirect].
///
/// Corresponds to [GoRoute.redirect].
FutureOr<String?> redirect(BuildContext context, GoRouterState state) => null;
/// [pageBuilder] is used to build the page
Page<void> pageBuilder(
BuildContext context,
GoRouterState state,
StatefulNavigationShell navigationShell,
) => const NoOpPage();
/// [builder] is used to build the widget
Widget builder(
BuildContext context,
GoRouterState state,
StatefulNavigationShell navigationShell,
) => throw UnimplementedError('One of `builder` or `pageBuilder` must be implemented.');
/// A helper function used by generated code.
///
/// Should not be used directly.
static StatefulShellRoute $route<T extends StatefulShellRouteData>({
required T Function(GoRouterState) factory,
required List<StatefulShellBranch> branches,
GlobalKey<NavigatorState>? parentNavigatorKey,
ShellNavigationContainerBuilder? navigatorContainerBuilder,
String? restorationScopeId,
}) {
T factoryImpl(GoRouterState state) {
return (_stateObjectExpando[state] ??= factory(state)) as T;
}
Widget builder(
BuildContext context,
GoRouterState state,
StatefulNavigationShell navigationShell,
) => factoryImpl(state).builder(context, state, navigationShell);
Page<void> pageBuilder(
BuildContext context,
GoRouterState state,
StatefulNavigationShell navigationShell,
) => factoryImpl(state).pageBuilder(context, state, navigationShell);
FutureOr<String?> redirect(BuildContext context, GoRouterState state) =>
factoryImpl(state).redirect(context, state);
if (navigatorContainerBuilder != null) {
return StatefulShellRoute(
branches: branches,
builder: builder,
pageBuilder: pageBuilder,
navigatorContainerBuilder: navigatorContainerBuilder,
parentNavigatorKey: parentNavigatorKey,
restorationScopeId: restorationScopeId,
redirect: redirect,
);
}
return StatefulShellRoute.indexedStack(
branches: branches,
builder: builder,
pageBuilder: pageBuilder,
parentNavigatorKey: parentNavigatorKey,
restorationScopeId: restorationScopeId,
redirect: redirect,
);
}
/// Used to cache [StatefulShellRouteData] that corresponds to a given [GoRouterState]
/// to minimize the number of times it has to be deserialized.
static final Expando<StatefulShellRouteData> _stateObjectExpando =
Expando<StatefulShellRouteData>('GoRouteState to StatefulShellRouteData expando');
}
/// Base class for supporting
/// [StatefulShellRoute](https://pub.dev/documentation/go_router/latest/go_router/StatefulShellRoute-class.html)
abstract class StatefulShellBranchData {
/// Default const constructor
const StatefulShellBranchData();
/// A helper function used by generated code.
///
/// Should not be used directly.
static StatefulShellBranch $branch<T extends StatefulShellBranchData>({
GlobalKey<NavigatorState>? navigatorKey,
List<RouteBase> routes = const <RouteBase>[],
List<NavigatorObserver>? observers,
String? initialLocation,
String? restorationScopeId,
bool preload = false,
Clip clipBehavior = Clip.hardEdge,
}) {
return StatefulShellBranch(
routes: routes,
navigatorKey: navigatorKey,
observers: observers,
initialLocation: initialLocation,
restorationScopeId: restorationScopeId,
preload: preload,
clipBehavior: clipBehavior,
);
}
}
/// A superclass for each typed route descendant
class TypedRoute<T extends RouteData> {
/// Default const constructor
const TypedRoute();
}
/// A superclass for each typed go route descendant
@Target(<TargetKind>{TargetKind.library, TargetKind.classType})
class TypedGoRoute<T extends GoRouteData> extends TypedRoute<T> {
/// Default const constructor
const TypedGoRoute({
required this.path,
this.name,
this.routes = const <TypedRoute<RouteData>>[],
this.caseSensitive = true,
});
/// The path that corresponds to this route.
///
/// See [GoRoute.path].
///
///
final String path;
/// The name that corresponds to this route.
/// Used by Analytics services such as Firebase Analytics
/// to log the screen views in their system.
///
/// See [GoRoute.name].
///
final String? name;
/// Child route definitions.
///
/// See [RouteBase.routes].
final List<TypedRoute<RouteData>> routes;
/// Determines whether the route matching is case sensitive.
///
/// When `true`, the path must match the specified case. For example,
/// a route with `path: '/family/:fid'` will not match `/FaMiLy/f2`.
///
/// When `false`, the path matching is case insensitive. The route
/// with `path: '/family/:fid'` will match `/FaMiLy/f2`.
///
/// Defaults to `true`.
final bool caseSensitive;
}
/// A superclass for each typed relative go route descendant
@Target(<TargetKind>{TargetKind.library, TargetKind.classType})
class TypedRelativeGoRoute<T extends RelativeGoRouteData> extends TypedRoute<T> {
/// Default const constructor
const TypedRelativeGoRoute({
required this.path,
this.routes = const <TypedRoute<RouteData>>[],
this.caseSensitive = true,
});
/// The relative path that corresponds to this route.
///
/// See [GoRoute.path].
///
///
final String path;
/// Child route definitions.
///
/// See [RouteBase.routes].
final List<TypedRoute<RouteData>> routes;
/// Determines whether the route matching is case sensitive.
///
/// When `true`, the path must match the specified case. For example,
/// a route with `path: '/family/:fid'` will not match `/FaMiLy/f2`.
///
/// When `false`, the path matching is case insensitive. The route
/// with `path: '/family/:fid'` will match `/FaMiLy/f2`.
///
/// Defaults to `true`.
final bool caseSensitive;
}
/// A superclass for each typed shell route descendant
@Target(<TargetKind>{TargetKind.library, TargetKind.classType})
class TypedShellRoute<T extends ShellRouteData> extends TypedRoute<T> {
/// Default const constructor
const TypedShellRoute({
this.notifyRootObserver = true,
this.routes = const <TypedRoute<RouteData>>[],
});
/// Whether navigation changes within this shell route will notify the
/// GoRouter's observers.
///
/// See [ShellRouteBase.notifyRootObserver].
final bool notifyRootObserver;
/// Child route definitions.
///
/// See [RouteBase.routes].
final List<TypedRoute<RouteData>> routes;
}
/// A superclass for each typed shell route descendant
@Target(<TargetKind>{TargetKind.library, TargetKind.classType})
class TypedStatefulShellRoute<T extends StatefulShellRouteData> extends TypedRoute<T> {
/// Default const constructor
const TypedStatefulShellRoute({
this.notifyRootObserver = true,
this.branches = const <TypedStatefulShellBranch<StatefulShellBranchData>>[],
});
/// Whether navigation changes within this shell route will notify the
/// GoRouter's observers.
///
/// See [ShellRouteBase.notifyRootObserver].
final bool notifyRootObserver;
/// Child route definitions.
///
/// See [RouteBase.routes].
final List<TypedStatefulShellBranch<StatefulShellBranchData>> branches;
}
/// A superclass for each typed shell route descendant
@Target(<TargetKind>{TargetKind.library, TargetKind.classType})
class TypedStatefulShellBranch<T extends StatefulShellBranchData> {
/// Default const constructor
const TypedStatefulShellBranch({this.routes = const <TypedRoute<RouteData>>[]});
/// Child route definitions.
///
/// See [RouteBase.routes].
final List<TypedRoute<RouteData>> routes;
}
/// Internal class used to signal that the default page behavior should be used.
@internal
class NoOpPage extends Page<void> {
/// Creates an instance of NoOpPage;
const NoOpPage();
@override
Route<void> createRoute(BuildContext context) => throw UnsupportedError('Should never be called');
}
/// Signature of custom query parameter encoding.
///
/// The function takes a parameter value of type `T` and returns a string
/// representation suitable for use in a URI. The returned string is escaped to
/// be URL-safe.
///
/// For example, a parameter value of `'field with space'` will generate a query
/// parameter value of `'field+with+space'`.
typedef QueryParameterEncoder<T> = String Function(T value);
/// Signature for custom query parameter decoding functions.
///
/// Converts an encoded string from the URI into a parameter value of type `T`.
///
/// The [value] parameter contains the encoded string from the URI. if the
/// parameter is absent from the URI.
typedef QueryParameterDecoder<T> = T Function(String value);
/// Annotation to override the URI name for a route parameter.
@optionalTypeArgs
@Target({TargetKind.parameter})
class TypedQueryParameter<T> {
/// Annotation to override the URI name for a route parameter.
const TypedQueryParameter({this.name, this.encoder, this.decoder, this.compare})
: assert(
(encoder == null) == (decoder == null),
'encoder and decoder must both be provided together',
),
assert(
compare == null || encoder != null,
'compare function requires an encoder to be provided',
);
/// The name of the parameter in the URI.
///
/// If `null`, the kebab-case version of the parameter name will be used.
///
/// For example:
/// ```dart
/// class MyRoute extends GoRouteData with $MyRoute {
/// const MyRoute({
/// @TypedQueryParameter(name: 'custom_name') this.myParameter,
/// });
/// final String myParameter;
/// }
/// ```
///
/// This will result in a route that matches
/// `/my-route?custom_name=some_value` instead of the default
/// `/my-route?my-parameter=some_value`.
///
/// It is escaped to be URL-safe. For example `'field with space'` will
/// generate a query parameter named `'field+with+space'`.
final String? name;
/// A function that converts a parameter value to a string for use in the URI.
///
/// See [QueryParameterEncoder] for details.
final QueryParameterEncoder<T>? encoder;
/// A function that converts a string from the URI to a parameter value.
///
/// See [QueryParameterDecoder] for details.
final QueryParameterDecoder<T>? decoder;
/// A function that determines if two parameter values differ.
///
/// Returns `true` when the values differ and `false` when they match.
///
/// Used to decide whether to include a parameter in the URI when a default
/// value exists. If the parameter equals its default value, it is omitted
/// from the URI; otherwise, it is included.
///
/// This should be provided if the parameter has a default value and is is not
/// a primitive type.
final bool Function(T, T)? compare;
}