Introduction to the

Flutter is a cross-platform, high-fidelity, high-performance mobile application development framework launched by Google and open source. Dart allows developers to develop apps, a set of code that runs on both iOS and Android. Flutter provides a wealth of components, interfaces, and developers can quickly add native extensions to Flutter. The Flutter also uses a Native engine to render views, which is a great experience for users.

At both ends of app, we introduced the product and source code into our project respectively. These two methods correspond to two modes, namely packaging and development.

The product approach. During the packaging phase of the project, we integrated the Flutter -release into our project by introducing flutter-release products.

Source code. During the development phase, we developed the flutter requirements through the officially recommended source code.

Here’s the official recommendation: github.com/flutter/flu…

Next, I will explain the process of flutter embedding and pit removal through three modules of “What is in flutter products”, “introduction of products at both ends” and “Problem record”, and provide an idea. Other problems can be solved according to this idea.

What is in Flutter products

As you can see from your observations of the.ios &.Android in your Flutter project, this is what your main project wants, and our embedded content is mostly based on those two projects.

If not, run the flutter Packages get command to regenerate the. Ios &. Android projects.

iOS

You can see the general structure of the.ios folder.

1. App. framework contains our code data sections, images and so on

2. Flutter. Framework contains the contents of the Engine and Embedder layers, the underlying services of flutter

3. FlutterPluginRegistrant contains bridge, registered the source code

4. Podhelper. rb: script to loop bridge into pod using the plugin list in flutter-plugins

Android

  1. The Flutter library and engine: icudtl.dat, libflutter. So, and some class files. These are encapsulated in the flutter in the jar, this jar file is located in the flutter repository directory [flutter/bin/cache/artifacts/engine].
  2. Flutter project products: isolate_snapshot_data, isolate_snapshot_instr, vm_SNAPshot_data, vm_SNAPshot_instr, flutter_assets.
  3. Flutter Plugin: Aar files compiled by each Plugin.

Among them:

Isolate_snapshot_data Application data segment Isolate_SNAPshot_instr application instruction segment VM_SNAPshot_data VM data segment vm_SNAPshot_instr VM instruction segment

The way products are introduced at both ends

IOS is introduced through POD and Android through AAR.

We are actually writing scripts to export the product. The core commands of the script are the tools of Flutter and Android itself, including Build iOS and./gradlew assembleRelease. Flutter has its own problems. Another is that it makes it easier to cluster the products together rather than manually copy them one by one.

Android script production general idea:

1. Enter the flutter engineering. Android folder. / gradlew assembleRelease will hit a flutter – the aar package (in. Android/flutter/build/outputs/aar), Aar is missing flutter_assets. In fact, this folder and its contents can be seen in IO /flutter. Jar. However, flutter references failed to be embedded into Android because it went back to assets.

2. However, there are other official plug-ins including path_provider,share_preference, audioPlayer, etc. We also need to copy them. Here we found that there is a.flutter-plugins file in the folder of the flutter project. This file records the file location of the official plugin you are currently using for Flutter. We read the file location through the shell and find the aar to put together.

The general idea of iOS scripting:

The following products will be gathered into the.ios/Flutter folder. We will copy the entire.ios/Flutter file and write a podspec file pod into our main project

The flutter. Framework is copied from the flutter root directory stored in Generated. Xcconfig.

App. Framework goes without saying.

The path_provider,share_preference, and audioplayer are copied from the locations recorded in the.flutter-plugins folder to the.symlinks folder;

FlutterPluginRegistrant is introduced via POD;

The problem record

1.Android product AAR is missing a flutter_assets file. Problems & solutions mentioned above.

Error: VM snapshot must be valid. Error: VM snapshot must be valid. Your DART VM initialization failed. Or you go to the Flutter page and there is nothing there.

Look at a lot of data on this, and the solution is mostly clean rebuild. But it’s just a couple of files