Commit 735966b
feat: add reloadIsRestart to handle hot reload as a restart for web flutter#179448 (flutter#183233)
This PR fixes the --no-hot flag on web-server not working properly. When
running flutter run -d web-server --no-hot, the flag was ignored and hot
reload still occurred instead of performing hot restart.
Problem
When --no-hot was passed to disable hot reload on web, pressing 'r' in
the console would be ignored entirely. The terminal handler was checking
canHotReload, which was false when --no-hot was set, but it didn't
account for platforms like web where hot reload must always be
implemented as a hot restart.
Solution
Added a reloadIsRestart property to the ResidentHandlers abstract class
to indicate platforms where hot reload should be treated as restart.
Updated the terminal handler's 'r' key logic to allow the command when
either canHotReload is true OR reloadIsRestart is true. The web runner
already automatically converts reloads to restarts when needed.
Changes Made
[resident_runner.dart]: Added reloadIsRestart to ResidentHandlers
abstract class and implemented in ResidentRunner (returns false by
default)
[run_cold.dart]: Implemented reloadIsRestart getter (returns false)
[run_hot.dart]: Implemented reloadIsRestart getter (returns false)
[resident_web_runner.dart]: Already had proper reloadIsRestart
implementation
[terminal_handler_test.dart]: Added test case to verify 'r' key works
when reloadIsRestart=true and canHotReload=false
Before/After Behavior
Before:
```
$ flutter run -d web-server --no-hot
> r # User presses 'r'
# Nothing happens - command is ignored
```
After:
```
$ flutter run -d web-server --no-hot
> r # User presses 'r'
Performing hot restart... # ✅ Correctly performs hot restart
```
Testing
Added comprehensive test coverage with a new test case: "r -
reloadIsRestart when canHotReload is false (web --no-hot case)". All 96
existing terminal handler tests pass.
Fixes
Fixes flutter#179448
---------
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Co-authored-by: Ben Konyi <bkonyi@google.com>1 parent 9724add commit 735966b
4 files changed
Lines changed: 43 additions & 1 deletion
File tree
- packages/flutter_tools
- lib/src
- test/general.shard
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
576 | 576 | | |
577 | 577 | | |
578 | 578 | | |
| 579 | + | |
| 580 | + | |
| 581 | + | |
| 582 | + | |
| 583 | + | |
| 584 | + | |
579 | 585 | | |
580 | 586 | | |
581 | 587 | | |
| |||
1101 | 1107 | | |
1102 | 1108 | | |
1103 | 1109 | | |
| 1110 | + | |
1104 | 1111 | | |
1105 | 1112 | | |
1106 | 1113 | | |
| |||
1729 | 1736 | | |
1730 | 1737 | | |
1731 | 1738 | | |
1732 | | - | |
| 1739 | + | |
| 1740 | + | |
| 1741 | + | |
| 1742 | + | |
1733 | 1743 | | |
1734 | 1744 | | |
1735 | 1745 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
36 | 36 | | |
37 | 37 | | |
38 | 38 | | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
39 | 42 | | |
40 | 43 | | |
41 | 44 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
145 | 145 | | |
146 | 146 | | |
147 | 147 | | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
148 | 151 | | |
149 | 152 | | |
150 | 153 | | |
| |||
Lines changed: 26 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
863 | 863 | | |
864 | 864 | | |
865 | 865 | | |
| 866 | + | |
| 867 | + | |
| 868 | + | |
| 869 | + | |
| 870 | + | |
| 871 | + | |
| 872 | + | |
| 873 | + | |
| 874 | + | |
| 875 | + | |
| 876 | + | |
| 877 | + | |
| 878 | + | |
| 879 | + | |
| 880 | + | |
| 881 | + | |
| 882 | + | |
| 883 | + | |
| 884 | + | |
866 | 885 | | |
867 | 886 | | |
868 | 887 | | |
| |||
1532 | 1551 | | |
1533 | 1552 | | |
1534 | 1553 | | |
| 1554 | + | |
| 1555 | + | |
| 1556 | + | |
1535 | 1557 | | |
1536 | 1558 | | |
1537 | 1559 | | |
| |||
1563 | 1585 | | |
1564 | 1586 | | |
1565 | 1587 | | |
| 1588 | + | |
| 1589 | + | |
| 1590 | + | |
| 1591 | + | |
1566 | 1592 | | |
1567 | 1593 | | |
1568 | 1594 | | |
| |||
0 commit comments