a simple noob question about flutter assets seperation
Closed this issue ยท 4 comments
Hello there
thanks for this excellent package it's exactly what i was looking for
i have a small question
what is the best practice for seperating flutter assets like audio,images,etc.. for each flavor ?
or flutter is smart enough to reconize which assets to bundle when building the app ?
thank you for your time
Hi @ash2osh , you can put your assets file in the assets folder of your project, and link them in the pubspec.yaml.
Then, in your flavors.dart file you should reference the exact file according to flutter configuration.
After you ran the process, you will see a file in lib/pages, here the main_home_page.dart references the F.title getter, which changes according of the current build configuration specified in the main-<flavor_config>.dart.
You need to define a new getter in the F class, which switches over the existing build flavors and picks the correct one accordingly. Then you have to use this getter wherever you want in your dart code.
I need to extend the README, but you can better understand the process by reading this article:
https://medium.com/@angeloavv/easily-build-flavors-in-flutter-android-and-ios-with-flutter-flavorizr-d48cbf956e4
wow that was rapid response !!
thanks for the great article
what i am trying to clarify for exmple :
assets:
- assets/
and i have those assets in project/assets
- project/assets/apple.jpg ==>used in apple flavor
- project/assets/banana.jpg ==> used in banana flavor
will both be present in the final apk ??
Yes they will both be present in the final apk, unless you do some precompile manipulation scripts.
There's an interesting discussion here about flavor-specific and platform-specific assets organization.
flutter/flutter#21682
I'll keep an eye on it.
thanks man you are the best :)