You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
But this get very tedious when many assets are present and somewhat removes the point of FlutterGen except compilte-time safety.
PS:
Each asset (even when it is present in multiple flavors) has flavors field which always contains a single flavor at best. What is even the point of this field?
Describe the solution
I understand that FlutterGen doesn't want to impose its own folder structure requirements while flutter provides full customizability but without it such cases might not be possible to solve in a reasonable way.
What I suggest is to add additional layer of code generation. So it will generate all assets as it currently does (eg. basically mirroring tree structure of original folders) but also (can be configurable):
Each asset (even when it is present in multiple flavors) has flavors field which always contains a single flavor at best. What is even the point of this field?
The structure follows the conditionally bundling assets1 of Flutter to solve the previous blocking issue 2.
Flavors require a solid decision. There are several things I can imagine to implement the flavor feature:
Recognize flavors. There are a couple of ways:
Manually specify flavors through configuration, such as flutter_gen > assets > flavors. Users need to define each flavor with a corresponding path (say assets/demo for "demo", assets/app for "app").
Read all flavors from native (build.gradle, Runner.xcworkspace, etc). This would be hard to implement since the format is variant.
Make sure all flavored assets exist. For example, if assets/demo/1.jpg exists, then assets/app/2.jpg must exist. But that does not sound like a production solution since people should have a base flavor and other flavors are only subsets.
Make sure the flavored assets can be only accessed with the corresponding flavor. For example, you can only access assets/demo/2.jpg when the flavor is demo rather than app. Flutter already does its part, but with the gen library, I don't think we can provide good access to such assets.
Is there an existing issue for this?
Describe the problem
Common pattern for whitelabel solutions is to have different flavors folders per customer:
And after that you just get resource as:
"assets/${appFlavor}/logo.png"
Sadly, this is basically not possible to do with flutterGen. There is no way to "inject" flavor:
You cannot switch-case root flavor directory because types are different
$AssetsCustomer1Gen
vs$AssetsCustomer2Gen
:Basically the only solution I can see at this moment is to switch case for each "flavored" resource:
But this get very tedious when many assets are present and somewhat removes the point of FlutterGen except compilte-time safety.
PS:
Each asset (even when it is present in multiple flavors) has
flavors
field which always contains a single flavor at best. What is even the point of this field?Describe the solution
I understand that
FlutterGen
doesn't want to impose its own folder structure requirements while flutter provides full customizability but without it such cases might not be possible to solve in a reasonable way.What I suggest is to add additional layer of code generation. So it will generate all assets as it currently does (eg. basically mirroring tree structure of original folders) but also (can be configurable):
/assets/{flavor}/**
formatLets say we have following assets:
FlutterGen
can generate something like:Personally, I don't see any point in
flavors
field but in case there are any - this solution fits it.Additional context
It would also be greate if flavors can override common resources but it is no a part of current task.
Code of Conduct
The text was updated successfully, but these errors were encountered: