由于在国内访问Flutter有时可能会受到限制,Flutter官方为中国开发者搭建了临时镜像,大家可以将如下环境变量加入到用户环境变量中
Linux设置
export PUB_HOSTED_URL=https://pub.flutter-io.cn
export FLUTTER_STORAGE_BASE_URL=https://storage.flutter-io.cn
Windows设置
在CMD
中执行下面两个命令
set PUB_HOSTED_URL=https://pub.flutter-io.cn
set FLUTTER_STORAGE_BASE_URL=https://storage.flutter-io.cn
官网下载:https://flutter.dev/docs/development/tools/sdk/releases#windows
通过git
下载
git clone -b beta https://github.com/flutter/flutter.git
下载之后,windows下设置flutter
全局变量=>系统变量=>Path
进入flutter SDK
代码目录,双击flutter_console.bat
,显示如下
######## ## ## ## ######## ######## ######## ########
## ## ## ## ## ## ## ## ##
## ## ## ## ## ## ## ## ##
###### ## ## ## ## ## ###### ########
## ## ## ## ## ## ## ## ##
## ## ## ## ## ## ## ## ##
## ######## ####### ## ## ######## ## ##
WELCOME to the Flutter Console.
================================================================================
Use the console below this message to interact with the "flutter" command.
Run "flutter doctor" to check if your system is ready to run Flutter apps.
Run "flutter create <app_name>" to create a new Flutter project.
Run "flutter help" to see all available commands.
Want to use an IDE to interact with Flutter? https://flutter.dev/ide-setup/
Want to run the "flutter" command from any Command Prompt or PowerShell window?
Add Flutter to your PATH: https://flutter.dev/setup-windows/#update-your-path
================================================================================
D:\project\flutter>flutter doctor
╔════════════════════════════════════════════════════════════════════════════╗
║ Welcome to Flutter! - https://flutter.dev ║
║ ║
║ The Flutter tool anonymously reports feature usage statistics and crash ║
║ reports to Google in order to help Google contribute improvements to ║
║ Flutter over time. ║
║ ║
║ Read about data we send with crash reports: ║
║ https://github.com/flutter/flutter/wiki/Flutter-CLI-crash-reporting ║
║ ║
║ See Google's privacy policy: ║
║ https://www.google.com/intl/en/policies/privacy/ ║
║ ║
║ Use "flutter config --no-analytics" to disable analytics and crash ║
║ reporting. ║
╚════════════════════════════════════════════════════════════════════════════╝
Doctor summary (to see all details, run flutter doctor -v):
[√] Flutter (Channel stable, v1.5.4-hotfix.2, on Microsoft Windows [Version 6.1.7601], locale zh-CN)
[X] Android toolchain - develop for Android devices
X Unable to locate Android SDK.
Install Android Studio from: https://developer.android.com/studio/index.html
On first launch it will assist you in installing the Android SDK components.
(or visit https://flutter.dev/setup/#android-setup for detailed instructions).
If the Android SDK has been installed to a custom location, set ANDROID_HOME to that location.
You may also want to add it to your PATH environment variable.
[!] Android Studio (not installed)
[!] VS Code, 64-bit edition
X Flutter extension not installed; install from
https://marketplace.visualstudio.com/items?itemName=Dart-Code.flutter
[!] Connected device
! No devices available
! Doctor found issues in 4 categories.
从flutter doctor
命令结果中看到,Android Studio
没有安装,提提示了安装地址https://developer.android.com/studio/index.html (这个地址需要翻墙),或者从这个地址下载http://www.android-studio.org/ (不需翻墙)
Android Studio
安装不需再多言,按步就班装就可以了
安装好Android Studio
后,再次执行flutter doctor
D:\project\flutter>flutter doctor
Doctor summary (to see all details, run flutter doctor -v):
[√] Flutter (Channel stable, v1.5.4-hotfix.2, on Microsoft Windows [Version 6.1.7601], locale zh-CN)
[!] Android toolchain - develop for Android devices (Android SDK version 29.0.0)
X Android licenses not accepted. To resolve this, run: flutter doctor --android-licenses
[!] Android Studio (version 3.4)
X Flutter plugin not installed; this adds Flutter specific functionality.
X Dart plugin not installed; this adds Dart specific functionality.
[!] VS Code, 64-bit edition
X Flutter extension not installed; install from
https://marketplace.visualstudio.com/items?itemName=Dart-Code.flutter
[!] Connected device
! No devices available
! Doctor found issues in 4 categories.
从上一步的提示中,可以看到
Android licenses not accepted. To resolve this, run: flutter doctor --android-licenses
执行下面命令,一直输入y
就好了
flutter doctor --android-licenses
从上上一步,还可以看到报错
Flutter plugin not installed; this adds Flutter specific functionality.
Dart plugin not installed; this adds Dart specific functionality.
Android Studio
=>Configure=>PluginsDart plugin
会和Flutter plugin
一起安装,提示时,选择Yes
即可
显示下图时,表示Flutter plugin
已经安装好了,我们这时就可以创建Flutter
项目了
打开https://marketplace.visualstudio.com/items?itemName=Dart-Code.flutter
直接安装
如下可见,基本的环境已经全部安装好了
D:\project\flutter>flutter doctor
Doctor summary (to see all details, run flutter doctor -v):
[√] Flutter (Channel stable, v1.5.4-hotfix.2, on Microsoft Windows [Version 6.1.7601], locale zh-CN)
[√] Android toolchain - develop for Android devices (Android SDK version 29.0.0)
[√] Android Studio (version 3.4)
[√] VS Code, 64-bit edition
[!] Connected device
! No devices available
! Doctor found issues in 1 category.
flutter环境安装及各种问题
最近一直在持续的学习 Flutter,但一直没有发现有好用的网络调试工具,也不想太想使用 Charles 这个工具,后来发现了Facebook Flipper 这个工具,所以花了几天时间做了个 Flutter 版的 Flipper SDK。期间碰到了一些问题但 Flipper 项目的人迅速的帮忙。
今天我们就来看一下如何使用 Agora Flutter SDK 快速构建一个简单的移动跨平台视频通话应用。