Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit 6113ef9

Browse files
authored
[web] Update the url when route is replaced (#13003)
1 parent 414ad38 commit 6113ef9

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

lib/web_ui/lib/src/engine/window.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,7 @@ class EngineWindow extends ui.Window {
153153
final Map<String, dynamic> message = decoded.arguments;
154154
switch (decoded.method) {
155155
case 'routePushed':
156+
case 'routeReplaced':
156157
_browserHistory.setRouteName(message['routeName']);
157158
break;
158159
case 'routePopped':

lib/web_ui/test/engine/navigation_test.dart

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ void main() {
2222
engine.window.locationStrategy = _strategy = null;
2323
});
2424

25-
test('Tracks pushed and popped routes', () {
25+
test('Tracks pushed, replaced and popped routes', () {
2626
engine.window.sendPlatformMessage(
2727
'flutter/navigation',
2828
codec.encodeMethodCall(const engine.MethodCall(
@@ -62,5 +62,18 @@ void main() {
6262
emptyCallback,
6363
);
6464
expect(_strategy.path, '/bar/baz');
65+
66+
engine.window.sendPlatformMessage(
67+
'flutter/navigation',
68+
codec.encodeMethodCall(const engine.MethodCall(
69+
'routeReplaced',
70+
<String, dynamic>{
71+
'previousRouteName': '/bar/baz',
72+
'routeName': '/bar/baz2',
73+
},
74+
)),
75+
emptyCallback,
76+
);
77+
expect(_strategy.path, '/bar/baz2');
6578
});
6679
}

0 commit comments

Comments
 (0)