[FEATURE]: Reduce built bundle size
Description: We should make an effort to optimize our application size.
To complete this task please do the following:
- [ ] Investigate what files take up what size, and if any can be removed
- [ ] Remove unnecessary files
- [ ] Consider how we could further decrease the bundle size, eg. by taking out non-critical files etc. (Submit an issue with your findings, and we will consider what we can do)
Note:
We currently build with --no-tree-shake-icons for both iOS and Android!
These are the commands used in CICD:
IOS: flutter build ipa --release --export-options-plist=ExportOptions.plist --build-number $GITHUB_RUN_NUMBER --no-tree-shake-icons
ANDROID: flutter build appbundle --release --build-number $GITHUB_RUN_NUMBER --no-tree-shake-icons
References: https://docs.flutter.dev/perf/app-size https://medium.com/gytworkz/how-to-decrease-app-size-in-flutter-10461f91f168
https://itnext.io/flutter-minimizing-tips-42113f02b678 (Some tips)
Addding --obfuscate --split-debug-info=build-info/ reduces by about 2MB
Any reason why we are not tree shaking icons
static IconData fromString(String iconName) {
return ioniconsMapping[iconName] != null
? int.tryParse(ioniconsMapping[iconName]!) != null
? IoniconsData(int.tryParse(ioniconsMapping[iconName]!)!)
: CollactionIcons.collaction
: CollactionIcons.collaction;
}
We can actually extract only the icons we need from both.
Any reason why we are not tree shaking icons
static IconData fromString(String iconName) { return ioniconsMapping[iconName] != null ? int.tryParse(ioniconsMapping[iconName]!) != null ? IoniconsData(int.tryParse(ioniconsMapping[iconName]!)!) : CollactionIcons.collaction : CollactionIcons.collaction; }We can actually extract only the icons we need from both.
You can play around with it, but the reason is quite simple.
How will you know which icons the backend will want to display on a Commitment? You can't, therefore them all.
Some comments here that I noticed:
- We only use Rive for 1 RiveAnimation in our App, we could consider taking it out (~620 kb)
- Clean unused images:
- arrow_fwd.png
- diet.png
- user.png
- logo.svg
- profile.svg
Also noticed mocktail should be moved to dev_dependencies, not sure why it's not there already.
We might also be able to take out rxdart, our usage is quite limited, and we could definitely do without it.
I guess, all of this along with at least --obfuscate should be enough.