- 作为独立的页面进行加入,可以从原生页面跳转到Flutter页面,也可以从Flutter页面跳转到原生页面。
- 作为页面的一部分嵌入。
===================================================================================
既然是做混合开发,那么我们肯定是由Android原生项目的。假如native项目的路径是这样的:flutter/flutter_hybrid/native,那么我们需要在native上一层目录flutter_hybrid中创建Flutter module。
cd flutter/flutter_hybrid/
//创建支持AndroidX的flutter_module
flutter create --androidx -t module flutter_module
//创建不支持AndroidX的flutter_module
flutter create -t module flutter_module
所以我们在创建模块的时候首先要确定native项目是不是已经支持AndroidX,如果支持就需要加上 --androidx 参数。
输入后控制台打印如下:
$ flutter create -t module flutter_module
Creating project flutter_module…
flutter_module/test/widget_test.dart (created)
flutter_module/flutter_module.iml (created)
flutter_module/.gitignore (created)
flutter_module/.metadata (created)
flutter_module/pubspec.yaml (created)
flutter_module/README.md (created)
flutter_module/lib/main.dart (created)
flutter_module/flutter_module_android.iml (created)
flutter_module/.idea/libraries/Flutter_for_Android.xml (created)
flutter_module/.idea/libraries/Dart_SDK.xml (created)
flutter_module/.idea/modules.xml (created)
flutter_module/.idea/