Skip to content

Commit 33f7424

Browse files
📝 Improve the documentation
1 parent 2760560 commit 33f7424

File tree

3 files changed

+30
-9
lines changed

3 files changed

+30
-9
lines changed

packages/go_router/lib/go_router.dart

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -70,13 +70,22 @@ extension GoRouterHelper on BuildContext {
7070
extra: extra,
7171
);
7272

73-
/// Replaces the current location with the given one w/ optional query
74-
/// parameters, e.g. `/family/f2/person/p1?color=blue
73+
/// Replaces the top-most page of the page stack with the given URL location
74+
/// w/ optional query parameters, e.g. `/family/f2/person/p1?color=blue`.
75+
///
76+
/// See also:
77+
/// * [go] which navigates to the location.
78+
/// * [push] which pushes the location onto the page stack.
7579
void replace(String location, {Object? extra}) =>
7680
GoRouter.of(this).replace(location, extra: extra);
7781

78-
/// Replaces the current location with the named route w/ optional parameters,
79-
/// e.g. `name='person', params={'fid': 'f2', 'pid': 'p1'}`
82+
/// Replaces the top-most page of the page stack with the named route w/
83+
/// optional parameters, e.g. `name='person', params={'fid': 'f2', 'pid':
84+
/// 'p1'}`.
85+
///
86+
/// See also:
87+
/// * [goNamed] which navigates a named route.
88+
/// * [pushNamed] which pushes a named route onto the page stack.
8089
void replaceNamed(
8190
String name, {
8291
Map<String, String> params = const <String, String>{},

packages/go_router/lib/src/go_router.dart

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -160,8 +160,12 @@ class GoRouter extends ChangeNotifier with NavigatorObserver {
160160
extra: extra,
161161
);
162162

163-
/// Replaces the current location with the given one w/ optional query
164-
/// parameters, e.g. `/family/f2/person/p1?color=blue
163+
/// Replaces the top-most page of the page stack with the given URL location
164+
/// w/ optional query parameters, e.g. `/family/f2/person/p1?color=blue`.
165+
///
166+
/// See also:
167+
/// * [go] which navigates to the location.
168+
/// * [push] which pushes the location onto the page stack.
165169
void replace(String location, {Object? extra}) {
166170
routeInformationParser
167171
.parseRouteInformation(
@@ -172,8 +176,13 @@ class GoRouter extends ChangeNotifier with NavigatorObserver {
172176
});
173177
}
174178

175-
/// Replaces the current location with the named route w/ optional parameters,
176-
/// e.g. `name='person', params={'fid': 'f2', 'pid': 'p1'}`
179+
/// Replaces the top-most page of the page stack with the named route w/
180+
/// optional parameters, e.g. `name='person', params={'fid': 'f2', 'pid':
181+
/// 'p1'}`.
182+
///
183+
/// See also:
184+
/// * [goNamed] which navigates a named route.
185+
/// * [pushNamed] which pushes a named route onto the page stack.
177186
void replaceNamed(
178187
String name, {
179188
Map<String, String> params = const <String, String>{},

packages/go_router/lib/src/go_router_delegate.dart

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,10 @@ class GoRouterDelegate extends RouterDelegate<List<GoRouteMatch>>
6565
notifyListeners();
6666
}
6767

68-
/// Replaces the current location with the given one.
68+
/// Replaces the top-most page of the page stack with the given one.
69+
///
70+
/// See also:
71+
/// * [push] which pushes the given location onto the page stack.
6972
void replace(GoRouteMatch match) {
7073
_matches.last = match;
7174
notifyListeners();

0 commit comments

Comments
 (0)