Little knowledge, big challenge! This article is participating in the creation of " Tips for Programmers ".
I had a simple study before, and today I started to learn flutter, and recorded the knowledge points learned by flutter, and recorded my own knowledge points to learn.
1. Flutter installation
There are many online tutorials about flutter installation. Here, record your own installation of flutter environment, flutter's official website
After clicking, select install and we choose the macOS environment
Here we choose the stable version to download
- 1.1 Unzip and install the Flutter SDK
- 1.2 Configure the image file
We need to configure the image file after decompression, you can refer to the official website instructions
If you are installing or using Flutter in China, it may be helpful to use a trusted local mirror site that hosts Flutter dependencies. flutter
To instruct the Flutter tools to use an alternate storage location, you need to set two environment variables PUB_HOSTED_URL
and before running the command FLUTTER_STORAGE_BASE_URL
.
export PUB_HOSTED_URL=https://pub.flutter-io.cn
export FLUTTER_STORAGE_BASE_URL=https://storage.flutter-io.cn
复制代码
The new version of the Mac
computer terminal is used, zsh
and its configuration file path is ~/.zshrc
;
The old version Mac
of the computer terminal is used bash
, and its configuration file path is ~/.bash_profile
;
The default after the new system is zsh
that we will have two configuration files, so we only need to zshrc
add the following instructions at the end of the file to directly import bash_profile
all the environment variables in the filezshrc
if [ -f ~/.bash_profile ]; then
. ~/.bash_profile;
fi
复制代码
we configure
export PUB_HOSTED_URL=https://pub.flutter-io.cn #国内用户需要设置
export FLUTTER_STORAGE_BASE_URL=https://storage.flutter-io.cn #国内用户需要设置
export PATH=/Users/*****/****/flutter/bin:$PATH
复制代码
After the configuration is complete, reopen the terminal, or enter the command directly in the terminal to reload the configuration:
# zsh 指令
source ~/.zshrc
# bash 指令
source ~/.bash_profile
复制代码
2. android studio installation
We know that flutter is a cross-platform development, we need to use Xcode and android, android studio download Mac download address where we can install it according to the wizard, and then need to install several sdk
Install Android SDK Command-line Tools
- Install the plugin
We need to install two plugins Flutter
and dart
, after installation, restart to create a flutter project
3. Verification
Terminal input flutter doctor
:
Basically, there is no problem. Some warnings can be ignored. Let's create a flutter project and run it.
Create a default flutter project and run it with Xcode. It takes a long time for the first time.