Mono repo, add a package

This part is a follow-up on https://yapb.dev/2021/03/07/mono-repo-with-flutter-and-android-studio/.

In this part, we are going to add a package to an existing mono-repo.

Open a terminal and go to the packages folder.

GO TO PACKAGES FOLDER

cd ~/repos/0000000-demo_mono_repo_app-rubigo/packages

CREATE A FLUTTER PACKAGE

fvm flutter create -t package --org com.example --project-name my_package ./my_package

OPEN/RESTART ANDROID STUDIO

Android studio might not detect the new folder. Restarting Android Studio fixes that.

COMMIT MY_PACKAGE

From now on we will use Android Studio to review and commit files.

Choose “Commit”

ADD MY_PACKAGE AS A MODULE

Android Studio => File -> Project Structure => Modules => + => Import Module

Navigate to my_package folder and choose “Open”. Be aware that the initial folder that Android Studio suggests might not be part of your current project.

Select “Create module from existing sources”, choose “Next”
Choose “Next”
Choose “Next”
Choose “OK”

COMMIT ADD MY_PACKAGE AS A MODULE

Choose “Commit”

ADD MY_PACKAGE AS A DEPENDENCY

Open demo_mono_repo_app/pubspec.yaml and add my_package, and run pub get.

COMMIT ADD MY_PACKAGE AS A DEPENDENCY

Choose “Commit”

CHANGE MAIN.DART TO USE MY_PACKAGE

If you change the line _counter++ to the sample here below, the demo app will use the package to add the values. Hot reload also works while you make changes to the implementation in my_package, which is awesome.

COMMIT CHANGES TO MAIN.DART

Choose “Commit”

DONE

These are all the steps that are needed to add a package to the mono-repo.

If you want to know how to add a plugin to the mono-repo, you can continue reading with this post: https://yapb.dev/2021/03/07/mono-repo-add-a-plugin/

Published by Sander Roest

Professional app developer.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

<span>%d</span> bloggers like this: