Skip to content

Using resolution aware image sets with flavors #177909

@verscph

Description

@verscph

Steps to reproduce

  1. Create directory structure for resolution-aware asset sets
  2. add assets to pubspec.yaml
flutter:
  assets:
    - path: assets/production/images/
      flavors:
      - production
    - path: assets/staging/images/
      flavors:
      - staging
  1. Use the asset
    Image.asset('assets/$appFlavor/images/logo.png')
  2. 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
    Scaffold(
      body: Center(
        child: Image.asset('assets/$appFlavor/images/logo.png'),
      ),
    );

Screenshots or Video

Screenshots / Video demonstration

[Upload media here]

Logs

Logs
[Paste your logs here]

Flutter Doctor output

Doctor output
[✓] 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!

Metadata

Metadata

Assignees

No one assigned

    Labels

    a: assetsPackaging, accessing, or using assetsa: imagesLoading, displaying, rendering imagesfound in release: 3.35Found to occur in 3.35found in release: 3.38Found to occur in 3.38has reproducible stepsThe issue has been confirmed reproducible and is ready to work ont: gradle"flutter build" and "flutter run" on Androidteam-toolOwned by Flutter Tool teamtoolAffects the "flutter" command-line tool. See also t: labels.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions