如何在VS代码中启用Flutter热重新加载



场景

我正在使用基本计数器应用程序(在flutter create之后(

预期功能

我想在VS代码中启用热重新加载:

1. increase the count
2. change the primary color + save file
3.1 see the color change
3.2 see the count stay the same (preserving state)

实际行为

在所有情况下(保存、在控制台中点击r(r(,甚至点击闪电图标(,我都会得到一个Restarted application in Xms和一个热的重新启动

1. increase the count
2. change the primary color + save file
3.1 color changes
3.2 count is reset to 0 (state is lost)

我尝试了什么

  • 在手动和自动保存设置之间切换
  • dart.flutterHotReloadOnSave设置为all
  • dart.hotReloadOnSave设置为all
  • debugrun模式(ctrl+F5F5(启动应用程序

我的设置

  • Flutterv3.3.2
  • VS代码v1.71
  • 颤振扩展v3.48.0
  • 飞镖扩展v3.48.3

Hot Reload仅适用于非web设备(台式机、移动设备(。在网络上,任何对热重新加载的调用都会触发热重新启动(因为这是最接近的可用功能(。

本期跟踪了web的热重新加载:https://github.com/flutter/flutter/issues/53041

最新更新