studio 热重载应用_热重载 (Hot reload)

Flutter 的热重载功能可帮助您在无需重新启动应用程序的情况下快速、轻松地测试、构建用户界面、添加功能以及修复错误。通过将更新的源代码文件注入到正在运行的

Dart 虚拟机(VM) 来实现热重载。在虚拟机使用新的字段和函数更新类之后,

Flutter 框架会自动重新构建 widget 树,以便您可以快速查看更改的效果。

Flutter’s hot reload feature helps you quickly and

easily experiment, build UIs, add features, and fix bugs.

Hot reload works by injecting updated source code files into

the running Dart Virtual Machine (VM). After the VM

updates classes with the new versions of fields and functions,

the Flutter framework automatically rebuilds the widget tree,

allowing you to quickly view the effects of your changes.

如何热重载:

How to perform a hot reload

热重载 Flutter 应用:

To hot reload a Flutter app:

在支持 Flutter 编辑器

或终端窗口运行应用程序,物理机或虚拟器都可以。

Flutter 应用程序只有在调试模式下才能被热重载。

Run the app from a supported Flutter editor

or a terminal window.

Either a physical or virtual device can be the target.

Only Flutter apps in debug mode can be hot reloaded.

修改项目中的一个Dart文件。大多数类型的代码更改可以热重载;一些需要重新启动应用程序的更改列表,请参阅 特别情况。

Modify one of the Dart files in your project.

Most types of code changes can be hot reloaded;

for a list of changes that require a hot restart, see

Special cases.

如果您在支持 Flutter IDE 工具的 IDE /编辑器中工作,请选择 Save All (cmd-s/ctrl-s),或单击工具栏上的 Hot Reload 按钮。

If you’re working in an IDE/editor that supports Flutter’s IDE tools,

select Save All (cmd-s/ctrl-s), or click the hot reload

button on the toolbar.

如果您正在使用命令行 flutter run 运行应用程序,请在终端窗口输入 r。

If you’re running the app at the command line using flutter run,

enter r in the terminal window.

成功执行热重载后,您将在控制台中看到类似于以下内容的消息:

After a successful hot reload operation,

you’ll see a message in the console similar to:

Performing hot reload...

Reloaded 1 of 448 libraries in 978ms.

应用程序更新以反映您的更改,并且应用程序的当前状态将保留。您的应用程序将继续从之前运行热重载命令的位置开始执行。代码被更新并继续执行。

The app updates to reflect your change,

and the current state of the app is preserved.

Your app continues to execute from where it was prior to running

the hot reload command. The code updates and execution continues.

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() or initState().

(⌘\ in Intellij and Android Studio, ⌃F5 in VSCode)

Hot restart loads code changes into the VM,

and restarts the Flutter app, losing the app state.

(⇧⌘\ in IntelliJ and Android Studio, ⇧⌘F5 in VSCode)

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值