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
操作如下:
➜ ~ 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!
➜ ~
四、验证
运行时,热重载按钮变为橙色,可以点击。
快捷键保存编辑时,自动重载。