flutter 混合开发实现热更新

flutter混合开发后,在Xcode中运行工程,由于flutter项目没有运行起来,是没办法热更新的,但是这种场景是可以解决的

  1. Flutter和原生(这里只说iOS 参考https://www.cnblogs.com/qqcc1388/p/12693991.html)混合开发配置
  2. Xcode中运行App
  3. Flutter工程中(我这里是VSCode中)执行命令行
chenhaodeMac:flutter_project chenhao$ flutter attach
Syncing files to device iPhone 11 Pro Max...                            
 6,854ms (!)                                       

??  To hot reload changes while running, press "r". To hot restart (and rebuild state), press
"R".
An Observatory debugger and profiler on iPhone 11 Pro Max is available at:
http://127.0.0.1:64758/Ohwd6eZv1eY=/
For a more detailed help message, press "h". To detach, press "d"; to quit, press "q".

执行完flutter attack你会发现,命令行熟悉的页面出现了,此时试试看,在VSCode中做Flutter页面的修改,会直接修改模拟器中的页面

注意 需要先让native代码运行起来,在执行flutter attach

相关推荐