移动App混合开发之Flutter篇(1)---Flutter工程配置

开新坑,来讲讲混合开发怎么搞.

目前我们公司用的weex,在weex第一个大版本就入坑了

1
2
3
4
5
6
 "version": "0.12.2",


0.12.0
Released in Jun 9, 2017
Source | Signature | Checksum

为什么敢这么激进?

1领导强力

2 iOS和Android开发水平高,能搞定一切weex搞不定的

3 web开发人员水平高

但是现在2021了,有机会还是用Flutter吧

1
2
flutter create --template module master_flutter

创建Flutter工程

创建好就完事了,就一行命令搞定,其他暂时不用管.

下面的flutter build aar在集成Android工程的时候才需要,目前把代码推到git仓库就行了

1
flutter build aar
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
master_flutter git:(main) flutter build aar
Running "flutter pub get" in master_flutter... 765ms
Running Gradle task 'assembleAarDebug'...
Running Gradle task 'assembleAarDebug'... Done 63.9s
✓ Built build/host/outputs/repo.
Running Gradle task 'assembleAarProfile'...
Running Gradle task 'assembleAarProfile'... Done 49.8s
✓ Built build/host/outputs/repo.
Running Gradle task 'assembleAarRelease'...
Running Gradle task 'assembleAarRelease'... Done 45.4s
✓ Built build/host/outputs/repo.

Consuming the Module
1. Open <host>/app/build.gradle
2. Ensure you have the repositories configured, otherwise add them:

String storageUrl = System.env.FLUTTER_STORAGE_BASE_URL ?: "https://storage.googleapis.com"
repositories {
maven {
url '/Users/admin/workspace/native-mix-cross-platform/flutter/Master-Flutter/master_flutter/build/host/outputs/repo'
}
maven {
url '$storageUrl/download.flutter.io'
}
}

3. Make the host app depend on the Flutter module:

dependencies {
debugImplementation 'com.example.master_flutter:flutter_debug:1.0'
profileImplementation 'com.example.master_flutter:flutter_profile:1.0'
releaseImplementation 'com.example.master_flutter:flutter_release:1.0'
}


4. Add the `profile` build type:

android {
buildTypes {
profile {
initWith debug
}
}
}

To learn more, visit https://flutter.dev/go/build-aar

flutter build aar