欢迎访问移动开发之家(rcyd.net),关注移动开发教程。移动开发之家  移动开发问答|  每日更新
页面位置 : > > > 内容正文

Flutter“不能热加载(hot reload),热重载按钮灰色且无法点击”的解决方案,最遊記reload

来源: 开发者 投稿于  被查看 24642 次 评论:95

Flutter“不能热加载(hot reload),热重载按钮灰色且无法点击”的解决方案,最遊記reload


前言,Flutter的热重载(hot reload)功能可以帮助您在无需重新启动应用的情况下快速、轻松地进行测试、构建用户界面、添加功能以及修复错误。

通过将更新后的源代码文件注入正在运行的Dart虚拟机(VM)中来实现热重载。

在虚拟机使用新的的字段和函数更新类后,Flutter框架会自动重新构建widget树,以便您快速查看更改的效果。

要热重载一个Flutter应用程序:

一、现象:

Flutter 不能热加载 热重载按钮灰色,无法点击。

 

 

二、分析原因:

终端 flutter doctor 显示 NO_PROXY is not set

没有设置无代理的端口

终端:flutter doctor

  ~ flutter doctor                                   

Doctor summary (to see all details, run flutter doctor -v):

[✓] Flutter (Channel stable, v1.7.8, on Mac OS X 10.14.3 18D109, locale

    zh-Hans-CN)

 

[✓] Android toolchain - develop for Android devices (Android SDK version 29.0.1)

[✓] Xcode - develop for iOS and macOS (Xcode 10.2.1)

[✓] iOS tools - develop for iOS devices

[✓] Android Studio (version 3.5)

[✓] VS Code (version 1.41.1)

[!] Proxy Configuration

    ! NO_PROXY is not set

[✓] Connected device (1 available)

 

! Doctor found issues in 1 category.

 重点在于:NO_PROXY is not set

三、解决方案:

设置 NO_PROXY即可

1.启动终端

2.进入当前用户的home目录

cd ~ 或者  cd /users/YourMacUserName

3.输入touch .bash_profile

查看和编辑.bash_profile文件

1.终端输入open -e .bash_profile

2.编辑文件,新增 

export no_proxy="localhost,127.0.0.1"

3.关闭保存

最后更新配置的环境变量

输入:source .bash_profile

 

不懂这块的话,看这里设置Mac 终端走代理

操作如下:

  ~ cd ~ 

  ~ touch .bash_profile

  ~ open -e .bash_profile

  ~ source .bash_profile

  ~ flutter doctor                       

Doctor summary (to see all details, run flutter doctor -v):

[✓] Flutter (Channel stable, v1.7.8, on Mac OS X 10.14.3 18D109, locale

    zh-Hans-CN)

 

[✓] Android toolchain - develop for Android devices (Android SDK version 29.0.1)

[✓] Xcode - develop for iOS and macOS (Xcode 10.2.1)

[✓] iOS tools - develop for iOS devices

[✓] Android Studio (version 3.5)

[✓] VS Code (version 1.41.1)

[✓] Proxy Configuration

[✓] Connected device (1 available)

 

No issues found!

  ~ 

 

四、验证

运行时,热重载按钮变为橙色,可以点击。

快捷键保存编辑时,自动重载。

 

 

相关文章

    暂无相关文章

用户评论