避免国内被墙,设置镜像源:
export PUB_HOSTED_URL=https://pub.flutter-io.cn
export FLUTTER_STORAGE_BASE_URL=https://storage.flutter-io.cn
Windows直接添加上述环境变量即可。
下载Flitter安装包:
https://flutter.io/docs/development/tools/sdk/archive#windows
下载后解压会生成flutter目录,运行目录下的bat文件:
flutter_console.bat
添加flutter环境变量:
#将路径添加到环境变量的Path中
flutter\bin
检查flutter依赖:
flutter doctor
经过检测后,会提示你缺失的环境:
[-] Android toolchain - develop for Android devices
• Android SDK at D:\Android\sdk
✗ Android SDK is missing command line tools; download from https://goo.gl/XxQghQ
• Try re-installing or updating your Android SDK,
visit https://flutter.io/setup/#android-setup for detailed instructions.
环境无误后,启动AndroidStudio,安装flutter插件,重启后即可直接新建flutter项目。
开发预览
运行预览
附带命令:
#显示连接的设备
flutter devices
#运行项目
flutter run
#运行并检查错误
flutter run --verbose
#打包release
flutter build --release
flutter build apk
网友评论