In the first article, I will write about flutter, which I have been in contact with recently (my leader had a sudden idea to use Flutter for the subsequent unified page development 😿 after leaving IOS). First of all, to develop Flutter, we need to configure the local environment of Flutter, taking my MAC as an example

1. Download the latest Flutter SDK from Flutter Chinese here

The Dart environment is already included in the Flutter SDK, so there is no need to install the Dart environment and configure the environment path after decompression

exportPATH=(PATH to the flutter folder on your computer)/bin:$PATHexportPATH=(PATH to the flutter folder on your computer)/bin/cache/dart-sdk/bin:$PATHCopy the code

2. If the Flutter doctor is outside the country, the diameter should be fine, but if the Flutter Doctor is inside the wall, the mirror should be configured first

On the terminal, enter open ~/. Bash_profile and press Enter. Open the bash_profile file and add the following

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

You can check the mirror configuration on the Flutter website. After all the configuration is complete, run the Flutter Doctor to check the environment

Since I am only doing flutter integration for Android projects, I have only configured the environment for Flutter and Android Studio. As you can see, I put the square root in front of it

Download the Flutter and Dart plugins in Android Studio because you are integrating with the Android Project

4. Now you can start the integration

First, create a Module for Flutter in the Android project

The address of the Flutter SDK needs to be configured here

Next, you need to import the Flutter Module into your project. Open settings.gradle to configure the flutter Module project information

Notice here because of fluttermoduleNew is in the root directory of the project, so use.. If not, specify the full path evaluate(new File(
  settingsDir,
  '.. /flutter Module name /.android/include_flutter. Groovy '
))
rootProject.name = "Project Name"

include ': Flutter Module name '
project(': Flutter Module name ').projectDir = new File('.. /flutter Module name ')
Copy the code

After the configuration is complete, the project structure is shown as follows

The following code is written in the lib folder under flutter_module_test and don’t forget to reference the Flutter project in your project build.gradle

implementation project(path: ':flutter')
Copy the code

Now that you have successfully integrated the Flutter Module into your Android project, you can happily start flutter code development