Get started with Flutter, download the Flutter SDK and run it successfully on iOS Android platform. Editors: Xcode(11.3.1), Android Studio(3.2.1), VSCode(1.43.2).

1. InFlutter websiteDownload the latest available installation package, unpack it, and place it in the directory you want to install, remembering the directory of the file, such as:/Users/liupengkun/Documents/flutter_learn.

2. Open the terminal and enter the cliopen ~/.bash_profileAfter opening the file, add tools related to flutter to path:

// The path should be the same directory where you placed the Sdkexport PATH=/Users/liupengkun/Documents/flutter_learn/flutter/bin:$PATH
Copy the code

3. Use of mirror images. Because access to Flutter may sometimes be restricted in China, Flutter officials have created temporary images for Chinese developers (this image is a temporary image and is not guaranteed to be available at all timesUsing Flutter in ChinaTo get the latest news about the image server. :

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

4. Close the bash_profile file and runsource ~/.bash_profileUpdate configuration environment variables.

5. Run the command on the terminalflutter doctorDetection environment, reported the following problems:

Everyone’s environment is different, so the problems detected by the Flutter Doctor will vary. Because I used Xcode, Android Studio and VSCode on my computer before, I reported relatively few problems, but IntelliJ IDEA was not used much.

Let’s tackle the problem of reporting:

! Some Android licenses not accepted.  To resolve this, run: flutter doctor --android-licenses

Copy the code

That’s easy. Just accept these agreements. Execute flutter doctor — Android-licenses directly to the terminal, entering y and line wrap until the flutter doctor succeeds.

Those who qualify Flutter plugin not installed; Those who qualify Dart plugin not installed; This adds Flutter specific functionality. this adds Dart specific functionality.Copy the code

Open AS and install Flutter and Dart in Configure:

About! The issue of No devices available will be covered later.

Then re-execute flutter doctor on terminal:

As for IntelliJ IDEA, I seldom use IntelliJ IDEA for the time being. In fact, it is easy to solve the problem by installing Flutter and Dart plug-in in IntelliJ IDEA.

6. Create and run the Flutter project

CD to the project folder, then run:

flutter create hello_flutter
Copy the code

After a while, the project builds successfully:

Open the ios or Android project above and run it.

About! There is No device available problem. The conclusion of my test here is that it does not work if it is run by emulator. Only when it is run by real computer, there will be changes:


  • 2020.04.08 update
    • Problem 1: Flutter was installed and configured earlier, but is running laterflutter doctorWhen an errorzsh: command not found: flutterThe temporary solution is to executesource ~/.bash_profile; The radical solution is to make a copy.bash_profileFile, rename to.zprofile, terminal executionsource ~./zprofile.
    • Problem 2: running the project into the iOS emulator with VSCode alwaysLaunching..., using Xcode directly does not work, the solution is manually delete~/Library/Developer/Xcode/DerivedDataFile under folder, rerun.
    • Problem 3: Sometimes the command is stuckWaiting for another flutter command to release the startup lockThe solution is to delete the lockfile file in the /bin/cache/ installation directory of flutter.

The Mac configuration of the Flutter environment runs on both iOS and Android

For more Articles, see Articles