Flutter hybrid development (adding Flutter to existing applications)


浏览:839 次

Original text:

1、 Create a flutter module

Cd some/path/

Flutter creation -- template module my_ flutter

The above command allows us to select some/path/my_ A flutter module project is created under the flutter/directory. In this directory, we can execute some flutter commands just like other flutter independent projects, such as flutter running -- debugging or flutter building ios. You can also run this module project in Android Studio/IntelliJ or with the Flutter and Sprint plug-ins in code. This project includes a single view sample version of the module, which is a version before being embedded into the existing application, which is helpful for incremental testing of the pure flutter part of your code.

2、 Module Project Structure

My blog module directory structure is similar to a normal flutter application:

My Blog/

☆. Operating system/

│ ├── Runner.xcworkspace

│ └── Flutter/podhelper.rb

◎ -- Library/

│ L -- main part

☆ - Test/

L -- pubspec.yaml

Add Sprint code to the library/catalog.

Add flutter correlation to my_ Flutter/pubspec includes vibrating packages and plug-ins

The. ios file hidden folder contains an Xcode workspace where you can run your module project independently. It is a wrapper project for guiding flutter code, and contains help scripts to facilitate building frameworks or embedding module projects into existing applications using Cocopod.

Note: Add the customized Internet operating system code to your existing application project or plug-in, not to the module's. iOS system/directory. In the module The changes made in the iOS system/directory will not appear in the existing Internet operating system projects using this module, but will be overwritten by chatter.

Don't be right The operating system/directory performs source code control because it is automatically generated. Before building the module on the new machine, before using the flutter module to build the Internet operating system project, run the Pompo Bar in my blog directory to regenerate it IOS system/directory.

3、 Embed flutter modules into the

There are two ways to embed flutter into existing applications.

1. Coco pod and local Flutter SDK of the application (recommended).

2. Full local management: Package the gallop code compiled by the flutter engine and the flutter plug-in to generate a framework, then manually embed the framework and update the construction settings in the X code.

Using flutter will increase the package volume

1. Use cocoa pod+local Flutter SDK

Each developer has a locally installed version of the Flutter SDK. Simply build your application in X code to automatically run scripts to embed your sprint and plug-in code. This solution allows you to quickly iterate the latest flutter module using only X code.

The following example assumes that your existing applications and flutter modules are in the peer directory. If you have a different directory structure, you may need to adjust the relative path.

Some/Path/

☆ - My blog/

│L. Operating system/

│ L -- trembling/

│L. -- Podcast Assistant. rb

L -- My application/

L -- Podcast file

Add code to the podcast file

flutter_ application_ path='../my_ flutter'

Load file. jin (flutter_application_path, '. ios',' flutter ',' podhelper. rb ')

Add and install all flutters for each target using flutter_ pods(flutter_application_path)

Target "MyApp" to do

Install all flutters_ pods(flutter_application_path)

termination

Pod installation

When you change my_ flutter/pubspec. When the flutter plug-in dependencies are in the yaml file, you need to execute the Pompo Bar in your flutter module project directory to refresh the list of plug-ins read by the Podcast Assistant. rb script. Then install the pod on some/path/MyApps in the original project directory

Podcast assistant. rb script: embed your plug-in, Flutter. framework and application framework into the project

Generate configuration: respectively embed flutter in debug/release/profile mode

2. Use frame+manual embedding

Build frameworks and embed existing X code projects into the application by manually editing them.

Usage scenario: Your team members cannot install Flutter SDK and Coco pod locally or do not want to use Coco pod management.

Disadvantages: In the flutter module, you must run flutter to build the ios framework every time you make code changes

1. Generate Framework

The following example assumes that you want to generate a framework to some/path/my application/trembling/directory.

Flutter builds ios framework -- output=some/path/MyApp/flutter/

Some/path/MyApp/

L -- trembling/

☆ - Commissioning/

│Σ - Flutter. Framework

│❖ - Application framework

│☆ - FlutterPluginRegistrat.framework (only if you have plug-ins with iOS platform code)

│ └── example_ Plugin. framework (each plug-in is a separate framework)

☆ -- Personal data/

│Σ - Flutter. Framework

│❖ - Application framework

│  - FlutterPluginRegistrant.framework

│| -- Example plug-in framework

L -- Release/

☆ - Flutter. Frame

☆ - Application framework

☆ - FlutterPluginRegistant.framework

L -- Example plug-in framework

Note: Imported Flutter The framework and application framework paths should be consistent, otherwise the runtime will crash (such as Profile/Flutter. Framework and debugging/

相关资讯:
我不知道哪个APP更好?没关系。让我们来看看这个评估

我不知道哪个APP更好?没关系。让我们来看看这个评估

查看
Topco APP排行榜!

Topco APP排行榜!

查看
哪些拓客APP更可靠

哪些拓客APP更可靠

查看
有哪些方法可以有效提高APP产品的下载率?

有哪些方法可以有效提高APP产品的下载率?

查看
iOSApp扫描和检测3D对象的终极指南

iOSApp扫描和检测3D对象的终极指南

查看