Flutter Learning-01-Environmental Construction on Mac

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

image.pngAfter clicking, select install and we choose the macOS environment

image.pngHere we choose the stable version to download

  • 1.1 Unzip and install the Flutter SDK

image.png

  • 1.2 Configure the image file

We need to configure the image file after decompression, you can refer to the official website instructions

image.pngIf you are installing or using Flutter in China, it may be helpful to use a trusted local mirror site that hosts Flutter dependencies. flutterTo instruct the Flutter tools to use an alternate storage location, you need to set two environment variables PUB_HOSTED_URLand 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 Maccomputer terminal is used, zshand its configuration file path is ~/.zshrc;

The old version Macof the computer terminal is used bash, and its configuration file path is ~/.bash_profile;

image.pngThe default after the new system is zshthat we will have two configuration files, so we only need to zshrcadd the following instructions at the end of the file to directly import bash_profileall 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 image.pngwe can install it according to the wizard, and then need to install several sdk

image.pngInstall Android SDK Command-line Tools

  • Install the plugin

We need to install two plugins Flutterand dart, after installation, restart to create a flutter project

image.png

3. Verification

Terminal input flutter doctor:

image.pngBasically, there is no problem. Some warnings can be ignored. Let's create a flutter project and run it.

image.pngCreate a default flutter project and run it with Xcode. It takes a long time for the first time.

Screenshot 2021-10-17 11.47.50 pm.png

Guess you like

Origin juejin.im/post/7020305071456354311