Integrate multiple Flutter modules with Android

tanya anand
2 min readMay 11, 2022

When you check the official doc for add 2 app. you will find a limitation as below.

Packing multiple Flutter libraries into an application isn’t supported.

But this was our need.

Stuck here for a while!

Then, I came across an issue on Github. And, it worked like a charm for us.

The concept is called Umbrella Approach.

Where there exists a flutter Guardian module. Which further extends all other flutter modules as packages.

Our host App will interact with the flutter Guardian module only. Thus just one flutter module is connected with our host App.

Let's understand this with an example.

Suppose we have two flutter modules.

  1. Login
  2. Authentication

And, we want to integrate with the android host App.

Then we will import both as packages to a third flutter module called flutter_umbrella. And, connect flutter_umbrella with the Android host App.

Let’s understand the implementation with code.

Step 1:

Create a flutter project named flutter_umbrella.

Step 2:

Make sure you have kept the android host app, login, and authentication in the same folder.

Add the path to pubspec.yaml

you can also define a remote path as below.

Use flutter pub get to sync.

Step 3:

Add the following to main.dart

The redirection is done on basis of the initial route.
To know how to set the initial route. please check.

Now, you are all set up and ready to fly.

Photo by Gary Bendig on Unsplash

Note: for login and authentication module, while declaring assets like images always mention package name also.

Hope! This will help you somewhere.

Please share some love by commenting if you don't find something in your favor.🧚🏼

--

--