Skip to content

Commit 6f539b7

Browse files
committed
Share expando
1 parent 03aed74 commit 6f539b7

File tree

1 file changed

+7
-16
lines changed

1 file changed

+7
-16
lines changed

packages/go_router/lib/src/route_data.dart

Lines changed: 7 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,11 @@ abstract class _GoRouteData extends RouteData {
4545
static UnimplementedError get shouldBeGeneratedError => UnimplementedError(
4646
'Should be generated using [Type-safe routing](https://pub.dev/documentation/go_router/latest/topics/Type-safe%20routes-topic.html).',
4747
);
48+
49+
/// Used to cache [_GoRouteData] that corresponds to a given [GoRouterState]
50+
/// to minimize the number of times it has to be deserialized.
51+
static final Expando<_GoRouteData> stateObjectExpando =
52+
Expando<_GoRouteData>('GoRouteState to _GoRouteData expando');
4853
}
4954

5055
/// Helper to build a location string from a path and query parameters.
@@ -174,7 +179,7 @@ abstract class GoRouteData extends _GoRouteData {
174179
}) {
175180
final _GoRouteParameters params = _createGoRouteParameters<T>(
176181
factory: factory,
177-
expando: _stateObjectExpando,
182+
expando: _GoRouteData.stateObjectExpando,
178183
);
179184

180185
return GoRoute(
@@ -190,13 +195,6 @@ abstract class GoRouteData extends _GoRouteData {
190195
);
191196
}
192197

193-
/// Used to cache [GoRouteData] that corresponds to a given [GoRouterState]
194-
/// to minimize the number of times it has to be deserialized.
195-
static final Expando<_GoRouteData> _stateObjectExpando =
196-
Expando<_GoRouteData>(
197-
'GoRouteState to GoRouteData expando',
198-
);
199-
200198
/// The location of this route, e.g. /family/f2/person/p1
201199
String get location => throw _GoRouteData.shouldBeGeneratedError;
202200

@@ -293,7 +291,7 @@ abstract class RelativeGoRouteData extends _GoRouteData {
293291
}) {
294292
final _GoRouteParameters params = _createGoRouteParameters<T>(
295293
factory: factory,
296-
expando: _stateObjectExpando,
294+
expando: _GoRouteData.stateObjectExpando,
297295
);
298296

299297
return GoRoute(
@@ -308,13 +306,6 @@ abstract class RelativeGoRouteData extends _GoRouteData {
308306
);
309307
}
310308

311-
/// Used to cache [RelativeGoRouteData] that corresponds to a given [GoRouterState]
312-
/// to minimize the number of times it has to be deserialized.
313-
static final Expando<_GoRouteData> _stateObjectExpando =
314-
Expando<_GoRouteData>(
315-
'GoRouteState to RelativeGoRouteData expando',
316-
);
317-
318309
/// The sub-location of this route, e.g. person/p1
319310
String get subLocation => throw _GoRouteData.shouldBeGeneratedError;
320311

0 commit comments

Comments
 (0)