How can I make my Flutter app work also as a module app?

Viewed 3537

I've created a Flutter standalone app and it's all working fine. But now I want to integrate some of the screens of that Flutter app in an existing Android/iOS app.

Is it possible?

2 Answers

Yes.

I could make it work by adding this at the end of the pubspec.yaml:

module:
  androidPackage: com.teste.embeded
  iosBundleIdentifier: com.teste.embeded

Add this and then call a packages get. This will create 2 hidden folders in your project structure: .android and .ios.

Becareful with the identation! This settings must be inside the flutter: tag, like this:

flutter:  
  uses-material-design: true
  assets:
    - images/a_dot_burr.jpeg
    - images/a_dot_ham.jpeg
  module:
    androidPackage: com.test.embeded
    iosBundleIdentifier: com.test.embeded

After doing this, follow the documentation for the Android/iOS sides (skip the module creating parts).

https://github.com/flutter/flutter/wiki/Add-Flutter-to-existing-apps

You can do that in tow ways:
1- Convert your project to Flutter module and then put that along side the native project and call your FlutterActivity from native
2- Convert your project to Flutter module and make an AAR from it ant import in the native project

Read this Flutter documentation:
https://flutter.dev/docs/development/add-to-app/android/project-setup

Related