[web] Update the url when route is replaced (#13003)

This commit is contained in:
Mouad Debbar
2019-10-08 14:47:25 -07:00
committed by GitHub
parent 414ad38662
commit 6113ef93ea
2 changed files with 15 additions and 1 deletions
+1
View File
@@ -153,6 +153,7 @@ class EngineWindow extends ui.Window {
final Map<String, dynamic> message = decoded.arguments;
switch (decoded.method) {
case 'routePushed':
case 'routeReplaced':
_browserHistory.setRouteName(message['routeName']);
break;
case 'routePopped':
+14 -1
View File
@@ -22,7 +22,7 @@ void main() {
engine.window.locationStrategy = _strategy = null;
});
test('Tracks pushed and popped routes', () {
test('Tracks pushed, replaced and popped routes', () {
engine.window.sendPlatformMessage(
'flutter/navigation',
codec.encodeMethodCall(const engine.MethodCall(
@@ -62,5 +62,18 @@ void main() {
emptyCallback,
);
expect(_strategy.path, '/bar/baz');
engine.window.sendPlatformMessage(
'flutter/navigation',
codec.encodeMethodCall(const engine.MethodCall(
'routeReplaced',
<String, dynamic>{
'previousRouteName': '/bar/baz',
'routeName': '/bar/baz2',
},
)),
emptyCallback,
);
expect(_strategy.path, '/bar/baz2');
});
}