Skip to content

Commit c69f5a8

Browse files
committed
Rename base class
1 parent 3711f6f commit c69f5a8

File tree

2 files changed

+152
-152
lines changed

2 files changed

+152
-152
lines changed

packages/go_router/lib/src/route_data.dart

Lines changed: 37 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ abstract class RouteData {
2121

2222
/// A base class for [GoRouteData] and [RelativeGoRouteData] that provides
2323
/// common functionality for type-safe routing.
24-
abstract class _GoRouteData extends RouteData {
25-
const _GoRouteData();
24+
abstract class _GoRouteDataBase extends RouteData {
25+
const _GoRouteDataBase();
2626

2727
/// Creates the [Widget] for `this` route.
2828
///
@@ -65,13 +65,13 @@ abstract class _GoRouteData extends RouteData {
6565
/// The error thrown when a user-facing method is not implemented by the
6666
/// generated code.
6767
static UnimplementedError get shouldBeGeneratedError => UnimplementedError(
68-
'Should be generated using [Type-safe routing](https://pub.dev/documentation/go_router/latest/topics/Type-safe%20routes-topic.html).',
69-
);
68+
'Should be generated using [Type-safe routing](https://pub.dev/documentation/go_router/latest/topics/Type-safe%20routes-topic.html).',
69+
);
7070

71-
/// Used to cache [_GoRouteData] that corresponds to a given [GoRouterState]
71+
/// Used to cache [_GoRouteDataBase] that corresponds to a given [GoRouterState]
7272
/// to minimize the number of times it has to be deserialized.
73-
static final Expando<_GoRouteData> stateObjectExpando =
74-
Expando<_GoRouteData>('GoRouteState to _GoRouteData expando');
73+
static final Expando<_GoRouteDataBase> stateObjectExpando =
74+
Expando<_GoRouteDataBase>('GoRouteState to _GoRouteDataBase expando');
7575
}
7676

7777
/// Helper to build a location string from a path and query parameters.
@@ -100,9 +100,9 @@ class _GoRouteParameters {
100100
}
101101

102102
/// Helper to create [GoRoute] parameters from a factory function and an Expando.
103-
_GoRouteParameters _createGoRouteParameters<T extends _GoRouteData>({
103+
_GoRouteParameters _createGoRouteParameters<T extends _GoRouteDataBase>({
104104
required T Function(GoRouterState) factory,
105-
required Expando<_GoRouteData> expando,
105+
required Expando<_GoRouteDataBase> expando,
106106
}) {
107107
T factoryImpl(GoRouterState state) {
108108
final Object? extra = state.extra;
@@ -117,14 +117,18 @@ _GoRouteParameters _createGoRouteParameters<T extends _GoRouteData>({
117117
}
118118

119119
return _GoRouteParameters(
120-
builder: (BuildContext context, GoRouterState state) =>
121-
factoryImpl(state).build(context, state),
122-
pageBuilder: (BuildContext context, GoRouterState state) =>
123-
factoryImpl(state).buildPage(context, state),
124-
redirect: (BuildContext context, GoRouterState state) =>
125-
factoryImpl(state).redirect(context, state),
126-
onExit: (BuildContext context, GoRouterState state) =>
127-
factoryImpl(state).onExit(context, state),
120+
builder:
121+
(BuildContext context, GoRouterState state) =>
122+
factoryImpl(state).build(context, state),
123+
pageBuilder:
124+
(BuildContext context, GoRouterState state) =>
125+
factoryImpl(state).buildPage(context, state),
126+
redirect:
127+
(BuildContext context, GoRouterState state) =>
128+
factoryImpl(state).redirect(context, state),
129+
onExit:
130+
(BuildContext context, GoRouterState state) =>
131+
factoryImpl(state).onExit(context, state),
128132
);
129133
}
130134

@@ -134,7 +138,7 @@ _GoRouteParameters _createGoRouteParameters<T extends _GoRouteData>({
134138
/// Subclasses must override one of [build], [buildPage], or
135139
/// [redirect].
136140
/// {@category Type-safe routes}
137-
abstract class GoRouteData extends _GoRouteData {
141+
abstract class GoRouteData extends _GoRouteDataBase {
138142
/// Allows subclasses to have `const` constructors.
139143
///
140144
/// [GoRouteData] is abstract and cannot be instantiated directly.
@@ -159,7 +163,7 @@ abstract class GoRouteData extends _GoRouteData {
159163
}) {
160164
final _GoRouteParameters params = _createGoRouteParameters<T>(
161165
factory: factory,
162-
expando: _GoRouteData.stateObjectExpando,
166+
expando: _GoRouteDataBase.stateObjectExpando,
163167
);
164168

165169
return GoRoute(
@@ -176,18 +180,19 @@ abstract class GoRouteData extends _GoRouteData {
176180
}
177181

178182
/// The location of this route, e.g. /family/f2/person/p1
179-
String get location => throw _GoRouteData.shouldBeGeneratedError;
183+
String get location => throw _GoRouteDataBase.shouldBeGeneratedError;
180184

181185
/// Navigate to the route.
182-
void go(BuildContext context) => throw _GoRouteData.shouldBeGeneratedError;
186+
void go(BuildContext context) =>
187+
throw _GoRouteDataBase.shouldBeGeneratedError;
183188

184189
/// Push the route onto the page stack.
185190
Future<T?> push<T>(BuildContext context) =>
186-
throw _GoRouteData.shouldBeGeneratedError;
191+
throw _GoRouteDataBase.shouldBeGeneratedError;
187192

188193
/// Replaces the top-most page of the page stack with the route.
189194
void pushReplacement(BuildContext context) =>
190-
throw _GoRouteData.shouldBeGeneratedError;
195+
throw _GoRouteDataBase.shouldBeGeneratedError;
191196

192197
/// Replaces the top-most page of the page stack with the route but treats
193198
/// it as the same page.
@@ -196,7 +201,7 @@ abstract class GoRouteData extends _GoRouteData {
196201
/// page animation.
197202
///
198203
void replace(BuildContext context) =>
199-
throw _GoRouteData.shouldBeGeneratedError;
204+
throw _GoRouteDataBase.shouldBeGeneratedError;
200205
}
201206

202207
/// A class to represent a relative [GoRoute] in
@@ -205,7 +210,7 @@ abstract class GoRouteData extends _GoRouteData {
205210
/// Subclasses must override one of [build], [buildPage], or
206211
/// [redirect].
207212
/// {@category Type-safe routes}
208-
abstract class RelativeGoRouteData extends _GoRouteData {
213+
abstract class RelativeGoRouteData extends _GoRouteDataBase {
209214
/// Allows subclasses to have `const` constructors.
210215
///
211216
/// [RelativeGoRouteData] is abstract and cannot be instantiated directly.
@@ -229,7 +234,7 @@ abstract class RelativeGoRouteData extends _GoRouteData {
229234
}) {
230235
final _GoRouteParameters params = _createGoRouteParameters<T>(
231236
factory: factory,
232-
expando: _GoRouteData.stateObjectExpando,
237+
expando: _GoRouteDataBase.stateObjectExpando,
233238
);
234239

235240
return GoRoute(
@@ -245,22 +250,22 @@ abstract class RelativeGoRouteData extends _GoRouteData {
245250
}
246251

247252
/// The sub-location of this route, e.g. person/p1
248-
String get subLocation => throw _GoRouteData.shouldBeGeneratedError;
253+
String get subLocation => throw _GoRouteDataBase.shouldBeGeneratedError;
249254

250255
/// The relative location of this route, e.g. ./person/p1
251-
String get relativeLocation => throw _GoRouteData.shouldBeGeneratedError;
256+
String get relativeLocation => throw _GoRouteDataBase.shouldBeGeneratedError;
252257

253258
/// Navigate to the route.
254259
void goRelative(BuildContext context) =>
255-
throw _GoRouteData.shouldBeGeneratedError;
260+
throw _GoRouteDataBase.shouldBeGeneratedError;
256261

257262
/// Push the route onto the page stack.
258263
Future<T?> pushRelative<T>(BuildContext context) =>
259-
throw _GoRouteData.shouldBeGeneratedError;
264+
throw _GoRouteDataBase.shouldBeGeneratedError;
260265

261266
/// Replaces the top-most page of the page stack with the route.
262267
void pushReplacementRelative(BuildContext context) =>
263-
throw _GoRouteData.shouldBeGeneratedError;
268+
throw _GoRouteDataBase.shouldBeGeneratedError;
264269

265270
/// Replaces the top-most page of the page stack with the route but treats
266271
/// it as the same page.
@@ -269,7 +274,7 @@ abstract class RelativeGoRouteData extends _GoRouteData {
269274
/// page animation.
270275
///
271276
void replaceRelative(BuildContext context) =>
272-
throw _GoRouteData.shouldBeGeneratedError;
277+
throw _GoRouteDataBase.shouldBeGeneratedError;
273278
}
274279

275280
/// A class to represent a [ShellRoute] in

0 commit comments

Comments
 (0)