As a general rule, if the modified code is downstream of the root widget’s build method, then hot reload behaves as expected. However, if the modified code won’t be re-executed as a result of rebuilding the widget tree, then you won’t see its effects after hot reload
What is the difference between hot reload, hot restart, and full restart?
- Hot reload loads code changes into the VM and re-builds the widget tree, preserving the app state; it doesn’t rerun
main()orinitState(). (⌘\in Intellij and Android Studio,⌃F5in VSCode) - Hot restart loads code changes into the VM, and restarts the Flutter app, losing the app state. (
⇧⌘\in IntelliJ and Android Studio,⇧⌘F5in VSCode) - Full restart restarts the iOS, Android, or web app. This takes longer because it also recompiles the Java / Kotlin / ObjC / Swift code. On the web, it also restarts the Dart Development Compiler. There is no specific keyboard shortcut for this; you need to stop and start the run configuration.
Flutter web currently supports hot restart but not hot reload.

本文详细解释了Flutter开发中热重载、热重启及完全重启的区别与应用场景。热重载能在保留应用状态的同时快速加载代码变更并重建UI组件树;热重启则会重新加载代码并重启Flutter应用,但会丢失当前应用状态;而完全重启则会重新启动iOS、Android或Web应用,包括重新编译Java/Kotlin/ObjC/Swift代码。
最低0.47元/天 解锁文章
304

被折叠的 条评论
为什么被折叠?



