基础环境配置:https://github.com/flutter/flutter/wiki/Add-Flutter-to-existing-apps

Android添加流程

  1. flutter create -t module my_flutter
  2. cd .android
    ./gradlew flutter:assembleDebug
  3. build.gradle
compileOptions {
  sourceCompatibility 1.8
  targetCompatibility 1.8
}
  1. settings.gradle 路径自调整
include ':app'  // assumed existing content
setBinding(new Binding([gradle: this]))
evaluate(new File(                            
  settingsDir.parentFile,                       
  'my_flutter/.android/include_flutter.groovy'  
))    
  1. 在需要使用的Module中build.gradle添加
dependencies {
  implementation project(':flutter')
  :
}
  1. 修改pubspec.yaml,只需要运行
flutter packages get

iOS添加流程

  1. flutter create -t module my_flutter
  2. Podfile
flutter_application_path = 'path/to/my_flutter/'
  eval(File.read(File.join(flutter_application_path, '.ios', 'Flutter', 'podhelper.rb')), binding)
}
  1. pod install
  2. Disable Bitcode
  3. 添加New Run Script Phase
"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh" build
"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh" embed
  1. 修改pubspec.yaml,运行
flutter packages get
pod install

这里只是进行了基础环境配置,接下去如果进行解耦开发呢?
Flutter-现有项目添加Flutter之项目分离

Flutter-现有项目添加Flutter之基础环境