Skip to content

Update 'Asset variants' on 'Adding assets and images' page #8452

@andrewkolos

Description

@andrewkolos

Page URL

https://docs.flutter.dev/development/ui/assets-and-images/

Page source

https://github.com/flutter/website/tree/main/src/development/ui/assets-and-images.md

Describe the problem

Asset variants states:

When an asset’s path is specified in the assets section of pubspec.yaml, the build process looks for any files with the same name in adjacent subdirectories. Such files are then included in the asset bundle along with the specified asset.

As of flutter/flutter@cb5b5c34, this is no longer the case. The flutter tool's automatic addition of files to the asset bundle is now limited to resolution-aware image assets. For example, if a project's pubspec.yaml file declares mountain.png as an asset, then 2.0x/mountain.png would be bundled, but night-time/mountain.png would not.

The change has understandably caused confusion (for example, flutter/flutter#121474), and this page should be updated.

Expected fix

Consider updating Declaring resolution-aware image assets to describe the automatic bundling of resolution-aware variants. Then, Asset variants can be deleted entirely.

Additional context

No response

Metadata

Metadata

Assignees

Labels

e1-hoursEffort: < 8 hrsfrom.page-issueReported in a reader-filed concernp2-mediumNecessary but not urgent concern. Resolve when possible.t.ui.generalRelates to general Flutter app UI topics

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions