Fixes hot restart correctly reset the browser history (flutter/engine#24377)

This commit is contained in:
chunhtai
2021-02-16 23:46:01 -08:00
committed by GitHub
parent 8f027e6a6b
commit 3685fe8a97
4 changed files with 9 additions and 7 deletions

View File

@@ -32,6 +32,9 @@ class EngineFlutterWindow extends ui.SingletonFlutterWindow {
_browserHistory =
MultiEntriesBrowserHistory(urlStrategy: _customUrlStrategy);
}
registerHotRestartListener(() {
window.resetHistory();
});
}
final Object _windowId;
@@ -86,12 +89,11 @@ class EngineFlutterWindow extends ui.SingletonFlutterWindow {
}
}
@visibleForTesting
Future<void> debugResetHistory() async {
Future<void> resetHistory() async {
await _browserHistory?.tearDown();
_browserHistory = null;
// Reset the globals too.
_usingRouter = false;
_isUrlStrategySet = false;
_customUrlStrategy = null;
}

View File

@@ -48,7 +48,7 @@ void testMain() {
tearDown(() async {
spy.tearDown();
await window.debugResetHistory();
await window.resetHistory();
});
test('basic setup works', () async {
@@ -262,7 +262,7 @@ void testMain() {
tearDown(() async {
spy.tearDown();
await window.debugResetHistory();
await window.resetHistory();
});
test('basic setup works', () async {

View File

@@ -28,7 +28,7 @@ void testMain() {
tearDown(() async {
_strategy = null;
await engine.window.debugResetHistory();
await engine.window.resetHistory();
});
test('Tracks pushed, replaced and popped routes', () async {

View File

@@ -33,7 +33,7 @@ void testMain() {
});
tearDown(() async {
await window.debugResetHistory();
await window.resetHistory();
window = null;
});