@@ -22,8 +22,8 @@ import 'state.dart';
22
22
/// The function signature of [GoRouter.onException] .
23
23
///
24
24
/// Use `state.error` to access the exception.
25
- typedef GoExceptionHandler = void Function (
26
- BuildContext context, GoRouterState state, GoRouter router);
25
+ typedef GoExceptionHandler =
26
+ void Function ( BuildContext context, GoRouterState state, GoRouter router);
27
27
28
28
/// A set of parameters that defines routing in GoRouter.
29
29
///
@@ -46,8 +46,7 @@ class RoutingConfig {
46
46
static FutureOr <String ?> _defaultRedirect (
47
47
BuildContext context,
48
48
GoRouterState state,
49
- ) =>
50
- null ;
49
+ ) => null ;
51
50
52
51
/// The supported routes.
53
52
///
@@ -184,23 +183,23 @@ class GoRouter implements RouterConfig<RouteMatchList> {
184
183
GlobalKey <NavigatorState >? navigatorKey,
185
184
String ? restorationScopeId,
186
185
bool requestFocus = true ,
187
- }) : _routingConfig = routingConfig,
188
- backButtonDispatcher = RootBackButtonDispatcher (),
189
- assert (
190
- initialExtra == null || initialLocation != null ,
191
- 'initialLocation must be set in order to use initialExtra' ,
192
- ),
193
- assert (
194
- ! overridePlatformDefaultLocation || initialLocation != null ,
195
- 'Initial location must be set to override platform default' ,
196
- ),
197
- assert (
198
- (onException == null ? 0 : 1 ) +
199
- (errorPageBuilder == null ? 0 : 1 ) +
200
- (errorBuilder == null ? 0 : 1 ) <
201
- 2 ,
202
- 'Only one of onException, errorPageBuilder, or errorBuilder can be provided.' ,
203
- ) {
186
+ }) : _routingConfig = routingConfig,
187
+ backButtonDispatcher = RootBackButtonDispatcher (),
188
+ assert (
189
+ initialExtra == null || initialLocation != null ,
190
+ 'initialLocation must be set in order to use initialExtra' ,
191
+ ),
192
+ assert (
193
+ ! overridePlatformDefaultLocation || initialLocation != null ,
194
+ 'Initial location must be set to override platform default' ,
195
+ ),
196
+ assert (
197
+ (onException == null ? 0 : 1 ) +
198
+ (errorPageBuilder == null ? 0 : 1 ) +
199
+ (errorBuilder == null ? 0 : 1 ) <
200
+ 2 ,
201
+ 'Only one of onException, errorPageBuilder, or errorBuilder can be provided.' ,
202
+ ) {
204
203
setLogging (enabled: debugLogDiagnostics);
205
204
WidgetsFlutterBinding .ensureInitialized ();
206
205
@@ -254,8 +253,9 @@ class GoRouter implements RouterConfig<RouteMatchList> {
254
253
requestFocus: requestFocus,
255
254
// wrap the returned Navigator to enable GoRouter.of(context).go() et al,
256
255
// allowing the caller to wrap the navigator themselves
257
- builderWithNav: (BuildContext context, Widget child) =>
258
- InheritedGoRouter (goRouter: this , child: child),
256
+ builderWithNav:
257
+ (BuildContext context, Widget child) =>
258
+ InheritedGoRouter (goRouter: this , child: child),
259
259
);
260
260
261
261
assert (() {
@@ -345,13 +345,12 @@ class GoRouter implements RouterConfig<RouteMatchList> {
345
345
Map <String , String > pathParameters = const < String , String > {},
346
346
Map <String , dynamic > queryParameters = const < String , dynamic > {},
347
347
String ? fragment,
348
- }) =>
349
- configuration.namedLocation (
350
- name,
351
- pathParameters: pathParameters,
352
- queryParameters: queryParameters,
353
- fragment: fragment,
354
- );
348
+ }) => configuration.namedLocation (
349
+ name,
350
+ pathParameters: pathParameters,
351
+ queryParameters: queryParameters,
352
+ fragment: fragment,
353
+ );
355
354
356
355
/// Navigate to a URI location w/ optional query parameters, e.g.
357
356
/// `/family/f2/person/p1?color=blue`
@@ -379,17 +378,16 @@ class GoRouter implements RouterConfig<RouteMatchList> {
379
378
Object ? extra,
380
379
String ? fragment,
381
380
}) =>
382
-
383
- /// Construct location with optional fragment, using null-safe navigation
384
- go (
385
- namedLocation (
386
- name,
387
- pathParameters: pathParameters,
388
- queryParameters: queryParameters,
389
- fragment: fragment,
390
- ),
391
- extra: extra,
392
- );
381
+ /// Construct location with optional fragment, using null-safe navigation
382
+ go (
383
+ namedLocation (
384
+ name,
385
+ pathParameters: pathParameters,
386
+ queryParameters: queryParameters,
387
+ fragment: fragment,
388
+ ),
389
+ extra: extra,
390
+ );
393
391
394
392
/// Push a URI location onto the page stack w/ optional query parameters, e.g.
395
393
/// `/family/f2/person/p1?color=blue` .
@@ -416,15 +414,14 @@ class GoRouter implements RouterConfig<RouteMatchList> {
416
414
Map <String , String > pathParameters = const < String , String > {},
417
415
Map <String , dynamic > queryParameters = const < String , dynamic > {},
418
416
Object ? extra,
419
- }) =>
420
- push <T >(
421
- namedLocation (
422
- name,
423
- pathParameters: pathParameters,
424
- queryParameters: queryParameters,
425
- ),
426
- extra: extra,
427
- );
417
+ }) => push <T >(
418
+ namedLocation (
419
+ name,
420
+ pathParameters: pathParameters,
421
+ queryParameters: queryParameters,
422
+ ),
423
+ extra: extra,
424
+ );
428
425
429
426
/// Replaces the top-most page of the page stack with the given URL location
430
427
/// w/ optional query parameters, e.g. `/family/f2/person/p1?color=blue` .
@@ -552,9 +549,11 @@ class GoRouter implements RouterConfig<RouteMatchList> {
552
549
553
550
/// The current GoRouter in the widget tree, if any.
554
551
static GoRouter ? maybeOf (BuildContext context) {
555
- final InheritedGoRouter ? inherited = context
556
- .getElementForInheritedWidgetOfExactType <InheritedGoRouter >()
557
- ? .widget as InheritedGoRouter ? ;
552
+ final InheritedGoRouter ? inherited =
553
+ context
554
+ .getElementForInheritedWidgetOfExactType <InheritedGoRouter >()
555
+ ? .widget
556
+ as InheritedGoRouter ? ;
558
557
if (inherited != null ) {
559
558
return inherited.goRouter;
560
559
}
0 commit comments