今天小编给大家推荐社区论坛上香港朋友 Michael Lee(Michaellee8) 制作的开源项目:《一个无需下载和编译代码就可以使用 Fuchsia 作 Flutter 开发的工具包》。在此想 Michael 表达诚挚的感谢,相信这个项目可以帮到很多朋友,项目地址是:https://github.com/michaellee8/flutter_fuchsia_toolchain 欢迎关注 repo 以及点 Star,支持和鼓励这位朋友!想和作者交流,欢迎加入讨论:https://forum.fuchsia-china.com/t//990
视频教程
欢迎订阅 Michael Lee 的频道,视频教程的地址是:https://youtu.be/gxV8EN9vzbc;在墙内的朋友无法观看,社区志愿者把它搬到了墙内,你也可以直接右键另存下载,如果可以访问 YouTube 记得关注一波作者频道,给作者一个支持和鼓励。
- 墙外地址:https://youtu.be/gxV8EN9vzbc
- 墙内地址:https://fuchsia-china.com/flutter-fuchsia-toolchain-video-tutorial
运行截图
命令用法
usage: flutterfx
bootstrap: init submodule and download required artifacts
update: update this repo and submodules
fuchsia <fserve|fpave|fserve-remote|fdevtools|fssh|fcp|femu|fpublish|fconfig|femu-exec-wrapper>: run <command> in the fuchsia sdk
flutter <command>: run <command> in the flutter sdk
readme: show the readme file
help: display this message
准备工作
使用以下命令安装必须的一些库和工具。 请注意:根据你所使用的操作系统或发行版的不同,这些命令可能会有所不同。下列命令是在 Ubuntu 18.04 使用。
sudo apt-get install curl unzip python2 \ libglu1-mesa bash curl git unzip xz-utils zip \ libvulkan1 mesa-vulkan-drivers
搭建使用 Flutter run
经过验证,热重载也可以正常工作。 在使用 Flutter run 启动 Flutter 应用程序后,在终端中按 “r” 键即可使用。
git clone https://github.com/michaellee8/flutter_fuchsia_toolchain.git --recursive # Assumes you have added ./bin to your path, if you haven't, use ./bin/flutterfx instead of flutterfx # You need to apply my patch at https://github.com/flutter/flutter/pull/55664/files before it is merged flutterfx bootstrap sudo ip tuntap add dev qemu mode tap user $USER && sudo ip link set qemu up flutterfx fuchsia femu -N --image qemu-x64 flutterfx fuchsia fserve --image qemu-x64 cd flutter_gallery # See Note 4 export FUCHSIA_SSH_CONFIG=$HOME/.fuchsia/sshconfig # See Note 2 flutterfx flutter run --verbose -d <flutter device name from flutterfx flutter devices>
重点来了,到底怎么在 Fuchsia 中运行 Flutter App呢?
当然咯,这也是你点开这篇文章和项目的原因。
下面命令假定的预设环境是 GNU/Linux 系统(Michael 使用的是 Ubuntu 18.04),建议最好和作者保持一致。你可能想在以后把自己搞迷糊,但是目前这是唯一验证可行的方法,注意准备一个连接状况良好的互联网,否则你就要等好几个小时了。
注意:(term1) (term2) (term3) 是表示不同的终端 terminal,因为你需要同时使用多个不同的终端。
cd ~
git clone https://github.com/michaellee8/flutter_fuchsia_toolchain.git --recursive
git clone https://github.com/michaellee8/flutter_gallery.git
# install ~/flutter_fuchsia_toolchain/bin to your path
# Before my PR being merged, you will need to apply the patch in
# https://github.com/flutter/flutter/pull/55715 to ./flutter
flutterfx bootstrap
sudo ip tuntap add dev qemu mode tap user $USER && sudo ip link set qemu up
(term1) cd flutter_gallery
(term1) flutterfx flutter pub get
(term1) flutterfx flutter build fuchsia --release --runner-source fuchsia.com \
--tree-shake-icons --verbose --target-platform fuchsia-x64
(term2) flutterfx fuchsia femu -N --image workstation.qemu-x64-release
(term3) flutterfx fuchsia fserve --image workstation.qemu-x64-release
(term1) flutterfx fuchsia fpublish ~/flutter_gallery/build/fuchsia/pkg/flutter_gallery-0.far
(term1) cd "$(flutterfx dir)/flutter/bin/cache/artifacts/flutter_runner/flutter/x64/release" && \
flutterfx fuchsia fpublish aot/flutter_aot_product_runner-0.far \
aot/dart_aot_product_runner-0.far jit/flutter_jit_product_runner-0.far \
aot/dart_jit_product_runner-0.far && cd ~/flutter_gallery
(term4) flutterfx fuchsia fssh log_listener
# in the ermine ui shell, type flutter_gallery and then press enter to launch it
# if you face Error while initializing the Dart VM: Wrong full snapshot version, expected
# you will need to do
# flutterfx flutter clean
# cd ~/flutter_fuchsia_toolchain/flutter/bin
# rm -rf ./cache
文件位置
- 当前目录
- ~/.fuchsia
快速命令
git clone https://github.com/michaellee8/flutter_fuchsia_toolchain.git --recursive sudo ip tuntap add dev qemu mode tap user $USER && sudo ip link set qemu up ifconfig qemu | grep inet6 flutterfx fuchsia femu -N --image workstation.qemu-x64-release flutterfx fuchsia fserve --image workstation.qemu-x64-release flutterfx fuchsia fpublish ~/gallery/build/fuchsia/pkg/gallery-0.far # if you are playing with flutter gallery flutterfx flutter build fuchsia --release --verbose --runner-source fuchsia.com --tree-shake-icons flutterfx flutter run -d <flutter device name from flutterfx flutter devices> flutterfx fuchsia fssh log_listener --clock Local
卸载/重新安装
rm -rf $(flutterfx dir) # This command will get you the installation location of the toolchain # and delete it completely rm -rf ~/flutter_gallery # If you cloned the flutter gallery there rm -rf ~/.fuchsia # Default location of fuchsis sdk's image and package cache
IDE 环境设置
你只需要把所使用 IDE 的 Flutter SDK 位置设置成 $(flutterfx dir)/flutter
即可,你如果你按照上方的指引做的话,它的路径应该是:~/flutter_fuchsia_toolchain/flutter
。
加入讨论
欢迎到论坛交流讨论:https://forum.fuchsia-china.com/t/990
Credits:
- 项目地址:https://github.com/michaellee8/flutter_fuchsia_toolchain
- Fuchsia OS 社区 Luaya 同学翻译文档 Readme 的前三段
- 本文配图合成自 Google 官方 Fuchsia logo 及 Flutter logo
[…] 为了方便观看,本文特意将《一个无需下载和编译代码就可以使用 Fuchsia 作 Flutter 开发的工具包》中提到的视频教程单独搬到墙内,方便一遍查看文字教程,一边查看视频。项目和视频原作者为 Michael Lee (Michaellee8),欢迎点 Star ,给作者一些鼓励和支持。 […]