热重载是 Flutter 最受欢迎的功能之一——它让你看到代码更改在正在运行的应用中几乎立即反映(亚秒级),无需重新启动应用或丢失其当前状态。它显著加快了开发和实验的速度。
热重载的作用
text
HOT RELOAD injects updated code into the RUNNING app:
→ make a code change → save → see it reflected in ~1 second
→ the app KEEPS its current STATE (you stay on the same screen, with the same data)
→ no full restart, no re-navigating to where you were
→ Edit UI/logic and see the result almost immediately while the app runs.
热重载 vs 热重启
text
HOT RELOAD → injects changes, PRESERVES app state (fast, ~1s) — for most UI/code changes
HOT RESTART → restarts the app, RESETS state (a bit slower) — for changes hot reload
can't handle (e.g. changes to main(), global state initialization, some structural changes)
FULL RESTART → rebuild and relaunch (slowest) — for native code changes, deep changes
