Repository navigation
Support different set of assets depending on --flavor xxx #21682
Description
Activity
- addedc: new featureNothing broken; request for a new capabilityNothing broken; request for a new capabilitya: assetsPackaging, accessing, or using assetsPackaging, accessing, or using assets
on Sep 11, 2018 - addedtoolAffects the "flutter" command-line tool. See also t: labels.Affects the "flutter" command-line tool. See also t: labels.
on Dec 10, 2018 @zoechi
Shared assets could be defined inpubspec.yaml. What do you think ?@sestegra I don't think it's a good idea to define them in
pubspec.yaml, but as far as I am aware there are people drawing plans about that topic with better insight already than I have.See my proposal #25487
Reacted by Günter Zöchbauer@zoechi Sample project is available here
https://github.com/sestegra/flutter_assets_flavorsReacted by Günter Zöchbauer, Flutter Painter and kiaxseventh@sestegra
I check your project,that all asset adds to apk becuaseBundling of package assets
If the desired asset is specified in the pubspec.yaml file of the package, it is bundled automatically with the application. In particular, assets used by the package itself must be specified in its pubspec.yaml.A package can also choose to have assets in its lib/ folder that are not specified in its pubspec.yaml file. In this case, for those images to be bundled, the application has to specify which ones to include in its pubspec.yaml. For instance, a package named fancy_backgrounds could have the following files:
content_copy
.../lib/backgrounds/background1.png
.../lib/backgrounds/background2.png
.../lib/backgrounds/background3.png
To include, say, the first image, the pubspec.yaml of the application should specify it in the assets section:content_copy
flutter:
assets:
- packages/fancy_backgrounds/backgrounds/background1.png
The lib/ is implied, so it should not be included in the asset path.https://flutter.dev/docs/development/ui/assets-and-images#from-packages
SceenShot about analysis apk
https://imgur.com/2HmGHC1@yousifk Good remark, but I won't have time to update my pull request #25487 to support further versions. In fact, this pull request only supports Flutter 1.0.0.
Moreover, I guess that Flutter team wouldn't integrate it in short terms.
I suggest you to develop some scripts to updatepubspec.yamlwhen compiling different flavors and/or targets.Reacted by Yousif Khalid, Fbrusca and Pedro Santos@sestegra
Thanks so much ... I do it .bat script
I will share it at githubany update?
Reacted by Robin Bonnes, Lucas Didur and Andrey Gordeev#41094
This PR is mainly for the specific loading of resources for the flavor, and does not consider the factors of platform and mode. If you consider platform and mode, the idea is similar to the PR. The resources that need to be distinguished according to flavor/platform/mode are uniformly placed in a folder, and the name of the folder is specified by --flavor-assets-dir (or other parameters), so that it allows you to filter specific resources based on the flavor/platform/mode information in this folder.Reacted by tung1on1@Hixie do you recall the format you described several weeks (months) ago?
PandaGeek1024 commented
on Dec 10, 2019 on Dec 10, 2019 · Hidden as off-topicshow commentMore actions55 remaining items
- addedteam-toolOwned by Flutter Tool teamOwned by Flutter Tool teamtriaged-toolTriaged by Flutter Tool teamTriaged by Flutter Tool team
on Jul 8, 2023 I've written a proposal in the form of a design document, Flavor-specific Assets. This will be discussed in the next Dash Forum (August 8th, US time).
Reacted by Daniel, b055man, renan jegouzo, Kyle Venn, marnberg and crissCMReacted by Kyle VennReacted by Kyle VennReacted by Kyle VennRegarding to flavors, there is one more thing to be discussed. You probably know how it works with native Android apps. You can declare
mainresources and all flavors will use them, unless you overwrite any item for specific flavor. So, there's not need to duplicate assets, if you don't define any flavor specific one, default will be used.As far as I understand, all ideas that have been considered here assume full set of assets for each flavor, so some assets must be actually duplicated.
As far as I understand, all ideas that have been considered here assume full set of assets for each flavor, so some assets must be actually duplicated.
Duplicate declaration (or any kind of duplicate work) is something the designs try to avoid. For all the pubspec-based proposals on the design doc (as of 8/2), the user would only need to declare every asset (or asset directory) once. Said another way:
- If an asset is common to all flavors, the user would simply declare it without a
flavor. - If an asset is unique to a flavor (or subset of flavors), the user would add the flavor(s) to that asset entry (or asset
group, if choose to implement such a syntax).
I'll try to revise the document to make that aspect more clear. Also, anyone can comment on the doc using the comments feature in google docs, so feel free to add a comment to a part of the doc if it seems confusing.
Reacted by giaur500- If an asset is common to all flavors, the user would simply declare it without a
- addeddesign docTracks a design discussion documentTracks a design discussion document
on Aug 9, 2023 - added a commit that references this issue
on Dec 7, 2023 - addedr: fixedIssue is closed as already fixed in a newer versionIssue is closed as already fixed in a newer version
on Dec 8, 2023 - added a commit that references this issue
on Dec 8, 2023 Related #65065
This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of
flutter doctor -vand a minimal reproduction of the issue.- locked as resolved and limited conversation to collaborators
on Dec 23, 2023
Edit by @christopherfujino
A design doc for this proposal is at https://flutter.dev/go/flavor-specific-assets
I want to create different flavors of the app and they differ (among other things) on the used assets (icons, backgrounds, fonts, logos, ...)
Currently this seems to require to modify
pubspec.yamlbefore runningflutter buildbut that is cumbersome.
I'd prefer something like
where the shared assets and the assets where the file suffix matches the
--flavor xxxvalue are merged and the result used forflutter build.