Using resolution aware image sets with flavors
- Dominant language
- Dart
- Stars
- 179k
- Forks
- 31.1k
- PR merge metrics
- PR metrics pending
Description
### Steps to reproduce
1. [Create directory structure for resolution-aware asset sets](https://docs.flutter.dev/ui/assets/assets-and-images#resolution-aware)
2. add assets to pubspec.yaml
```
flutter:
assets:
- path: assets/production/images/
flavors:
- production
- path: assets/staging/images/
flavors:
- staging
```
3. Use the asset
`Image.asset('assets/$appFlavor/images/logo.png')`
4. flutter run --flavor staging
### Expected results
Based on the flavor, the resolution-aware asset is found and correctly displayed.
### Actual results
```
Unable to load asset: "assets/staging/images/logo.png". -Exception: Asset not found
```
When using `Image.asset('assets/$appFlavor/images/1.0x/logo.png')` the asset is found.
### Code sample
Code sample
```dart
Scaffold(
body: Center(
child: Image.asset('assets/$appFlavor/images/logo.png'),
),
);
```
### Screenshots or Video
Screenshots / Video demonstration
[Upload media here]
### Logs
Logs
```console
[Paste your logs here]
```
### Flutter Doctor output
Doctor output
```console
[✓] Flutter (Channel stable, 3.35.3, on macOS 26.0.1 25A362 darwin-arm64, locale en-US) [2.2s]
• Flutter version 3.35.3 on channel stable at /Users/philipverschueren/fvm/versions/3.35.3
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision a402d9a437 (9 weeks ago), 2025-09-03 14:54:31 -0700
• Engine revision ddf47dd3ff
• Dart version 3.9.2
• DevTools version 2.48.0
• Feature flags: enable-web, enable-linux-desktop, enable-macos-desktop, enable-windows-desktop, enable-android, enable-ios, cli-animations, enable-swift-package-manager, enable-lldb-debugging
[✓] Android toolchain - develop for Android devices (Android SDK version 36.0.0) [3.5s]
• Android SDK at /Users/philipverschueren/Library/Android/sdk
• Emulator version 36.1.9.0 (build_id 13823996) (CL:N/A)
• Platform android-36, build-tools 36.0.0
• Java binary at: /Applications/Android Studio.app/Contents/jbr/Contents/Home/bin/java
This JDK is specified in your Flutter configuration.
To change the current JDK, run: `flutter config --jdk-dir="path/to/jdk"`.
• Java version OpenJDK Runtime Environment (build 21.0.6+-13391695-b895.109)
• All Android licenses accepted.
[✓] Xcode - develop for iOS and macOS (Xcode 26.0.1) [2.7s]
• Xcode at /Applications/Xcode.app/Contents/Developer
• Build 17A400
• CocoaPods version 1.16.2
[✓] Chrome - develop for the web [5ms]
• Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
[✓] Android Studio (version 2025.1) [5ms]
• Android Studio at /Applications/Android Studio.app/Contents
• Flutter plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/9212-flutter
• Dart plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/6351-dart
• Java version OpenJDK Runtime Environment (build 21.0.6+-13391695-b895.109)
[✓] Connected device (4 available) [6.3s]
[✓] Network resources [558ms]
• All expected network resources are available.
• No issues found!
```
Contributor guide
Research direction
Reproduce the issue with the pubspec.yaml flavor entries, the resolution-aware assets directory structure, and Image.asset('assets/$appFlavor/images/logo.png') while running the staging flavor. Trace how the asset path is bundled and resolved; done means the base asset path finds the appropriate resolution-aware image for the selected flavor, without requiring an explicit 1.0x path.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- dart, flutter
- Domain
- mobile-dev
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100