Environment configuration

window

  1. The page for setting environment variables is displayed

This computer > Properties > Advanced System Settings > Environment Variables

Created in system environment variables

Note: This image is temporary and is not guaranteed to be available at all times

Variable name (N):PUB_HOSTED_URL Variable value (V):https://pub.flutter-io.cnCopy the code
Variable name :FLUTTER_STORAGE_BASE_URL Variable value :https://storage.flutter-io.cnCopy the code

If you have Git for Windows installed, make sure you run the Git command at the command prompt or PowerShell, Unable to find git in your PATH error: Failed to find git in your PATH. Add C: Program Files\ git \bin to the PATH environment variable manually.

  1. Access to Flutter the SDK

Github Releases folders with flutter. IO/SDK-archive…

Note that the channel version of Flutter is subject to change. Please refer to the Website of Flutter. In addition, you may need to climb the wall to get the list or download the package in Mainland China. You can also go to the Download page of Flutter Github to download the package.

Here’s a plan (trust your network) :

git clone -b dev https://github.com/flutter/flutter.git
Copy the code

Smaller than macOs, over 600 meters

  1. Unpack the

Unzip the install package to the path where you want to install the Flutter SDK

Note do not install flutter into a path that requires some high permissions such as C:\Program Files\).

  1. Double click on theflutter_console.bat

Go to the Flutter file in the Flutter installation directory and double-click flutter_console.bat to run and start the Flutter command line. Then you can run the Flutter command on the Flutter command line

  1. Checking Environment Variables
  • Check for an entry named “Path” under “User Variables” :
    • Append the full path of flutter\bin if the entry exists, use the. As a separator.
    • If the entry does not exist, create a new user variable Path and then take the full Path of flutter\bin as its value.
    • Under “User Variables” check for entries named “PUB_HOSTED_URL” and “FLUTTER_STORAGE_BASE_URL”, if not, add them as well.

Finally reboot the computer

  1. Run the flutter doctor

Open a new command prompt or PowerShell window and run the following command to see if any dependencies need to be installed to complete the installation

The first time a flutter command (such as a flutter Doctor) is run, it downloads its own dependencies and compiles them. It will run much faster later.

Once you have installed any missing dependencies, run the flutter doctor command again to verify that you have set up the flutter properly

 flutter doctor
Copy the code

macOS

Since access to Flutter may sometimes be restricted in China, Flutter officials have created a temporary mirror for Chinese developers who can add the following environment variables to their user environment variables:

  1. Open the environment variables file
Sudo open ~/. Bash_profile or sudo source ~/. Bash_profileCopy the code
  1. Configuring environment Variables

Note: This image is temporary and is not guaranteed to be available at all times

export PUB_HOSTED_URL=https://pub.flutter-io.cn
export FLUTTER_STORAGE_BASE_URL=https://storage.flutter-io.cn
Copy the code

Flutter relies on the following command-line tools: bash, mkdir, rm, git, curl, unzip, which

  1. Access to Flutter the SDK

Https://release.org/releases/github Releases: flutter. Dev /docs/develo…

Note that the channel version of Flutter is subject to change. Please refer to the Website of Flutter. In addition, you may need to climb the wall to get the list or download the package in Mainland China. You can also go to the Download page of Flutter Github to download the package.

Here’s a plan (trust your network) :

git clone -b dev https://github.com/flutter/flutter.git
Copy the code

It’s big. It’s over a G

  1. Decompress the installation package

Unzip the installation package to the directory you want to install

CD ~ / development unzip ~ / Downloads/flutter_macos_v0. 5.1 beta. ZipCopy the code

You can also use decompression tool, MY side is downloaded directly to me decompressed out

  1. addflutterPath to thepathIn the
export PATH="/Library/development/flutter/bin:$PATH"
Copy the code

This code can only temporarily set the PATH environment variable to the current command line window. To permanently add Flutter to PATH see the update environment variable section below

Restart the computer

  1. runflutter doctor
flutter doctor
Copy the code

This command examines your environment and displays the report in a terminal window. Dart SDK is already bundled into Flutter, there is no need to install Dart separately. Go through the command line output for additional software that may need to be installed or further tasks that may need to be performed (shown in bold) – no ❌ will do

  • [!] Develop Toolchain for Android Devices (Android SDK Version 30.0.3)! Some Android licenses not accepted. To resolve this, run: flutter doctor --android-licenses

To solve

flutter doctor --android-licenses
Copy the code

All the way y

Final return

Doctor summary (to see all details, run flutter doctor -v): ✓] Flutter (Channel stable, 2.2.0, on Mac OS X 10.15.7 19H114 Darwin-x64, ✓ ✓ Android toolchain-develop for Android Devices (Android SDK version 30.0.3) [✓] Xcode-develop Chrome - Develop for the web [✓] Android Studio (version 4.1) [✓] Connected device (1 available)Copy the code

Upgrade Flutter

We strongly recommend tracking the stable branch of flutter, which is the stable branch of flutter

The newly configured Path requires a reboot of the computer

flutter channel
Copy the code

Switch branch

Flutter Channel beta or flutter Channel masterCopy the code

Specify the Flutter SDK for your project

Pubspec.yaml (similar to package.json)[this file is found in every project] specifies the dependencies of the Flutter SDK

The following code snippet specifies that the flutter and Flutter_test packages use the Flutter SDK.

To view the flutter/examples/helloword

name: hello_world
dependencies:
  flutter:
    sdk: flutter
dev_dependencies:
  flutter_test:
    sdk: flutter
Copy the code

Upgrade Flutter channels and packages

To update both the Flutter SDK and your dependencies, run the Flutter upgrade command in your application root directory (the directory containing the pubspec.yaml file) :

flutter upgrade
Copy the code

Upgrade your dependency packages

If you modify the pubspec.yaml file, or just want to update the packages that your application depends on (excluding the Flutter SDK)

  • flutter packages getTo obtainpubspec.yamlAll dependency packages listed in the file
  • flutter packages upgradeTo obtainpubspec.yamlThe latest versions of all dependent packages listed in the file