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
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.
From now on we will use Android Studio to review and commit files.
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.
COMMIT ADD MY_PACKAGE AS A MODULE
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
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
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/