Flutter packages
or How to share code between your apps
Many of my apps communicate with a custom Bluetooth device. Also, many of my apps should have the same, or at least similar, branding. Therefore, many of my apps have common code.
We do NOT want duplicate code.
So we need a way to share code between apps.
There are two main options:
- Sharing a folder with Git Submodules.
- Sharing using a package with Flutter packages
Git Submodules
With Git Submodule, you basically insert a repository into another repository. So for the purpose of code sharing, this would look like this:
You have a separate git repository for your common code, but in your apps you pull from this repo into a subfolder. App1 sees the common code in the Util
subfolder, and App2 also sees the common code in the Util
subfolder (you can name the folder anything you wish, but this makes things clearer). The obvious pro of this method is that it’s very easy to change the common code as needed (the code of Util is right there).