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

Commit 17a1116

Browse files
authored
Fixes hot restart correctly reset the browser history (#24377)
1 parent c4a8de2 commit 17a1116

File tree

4 files changed

+9
-7
lines changed

4 files changed

+9
-7
lines changed

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

+5-3
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,9 @@ class EngineFlutterWindow extends ui.SingletonFlutterWindow {
3232
_browserHistory =
3333
MultiEntriesBrowserHistory(urlStrategy: _customUrlStrategy);
3434
}
35+
registerHotRestartListener(() {
36+
window.resetHistory();
37+
});
3538
}
3639

3740
final Object _windowId;
@@ -86,12 +89,11 @@ class EngineFlutterWindow extends ui.SingletonFlutterWindow {
8689
}
8790
}
8891

89-
@visibleForTesting
90-
Future<void> debugResetHistory() async {
92+
Future<void> resetHistory() async {
9193
await _browserHistory?.tearDown();
9294
_browserHistory = null;
93-
9495
// Reset the globals too.
96+
_usingRouter = false;
9597
_isUrlStrategySet = false;
9698
_customUrlStrategy = null;
9799
}

lib/web_ui/test/engine/history_test.dart

+2-2
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ void testMain() {
4848

4949
tearDown(() async {
5050
spy.tearDown();
51-
await window.debugResetHistory();
51+
await window.resetHistory();
5252
});
5353

5454
test('basic setup works', () async {
@@ -262,7 +262,7 @@ void testMain() {
262262

263263
tearDown(() async {
264264
spy.tearDown();
265-
await window.debugResetHistory();
265+
await window.resetHistory();
266266
});
267267

268268
test('basic setup works', () async {

lib/web_ui/test/engine/navigation_test.dart

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ void testMain() {
2828

2929
tearDown(() async {
3030
_strategy = null;
31-
await engine.window.debugResetHistory();
31+
await engine.window.resetHistory();
3232
});
3333

3434
test('Tracks pushed, replaced and popped routes', () async {

lib/web_ui/test/window_test.dart

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ void testMain() {
3333
});
3434

3535
tearDown(() async {
36-
await window.debugResetHistory();
36+
await window.resetHistory();
3737
window = null;
3838
});
3939

0 commit comments

Comments
 (0)