Skip to content

appFlavor is null when running flutter test with --flavor option in 3.32 #169160

@alex-medinsh

Description

@alex-medinsh

Update: looks like the --flavor option does not populate the appFlavor variable too.

Steps to reproduce

  1. Define default-flavor in pubspec.yaml
# The following section is specific to Flutter packages.
flutter:
  default-flavor: dev
  1. Run flutter test
  2. Check the appFlavor variable inside a test

OR

  1. Run flutter test --flavor dev
  2. Check the appFlavor variable inside a test

This prints dev in 3.29.3. and null in 3.32

Expected results

appFlavor variable contains the selected flavor.

Actual results

appFlavor is null

Code sample

Code sample
import 'package:flutter/services.dart';
import 'package:flutter_test/flutter_test.dart';

void main() {
  test('prints default-flavor', () async {
    print(appFlavor);
  });
}

Screenshots or Video

Screenshots / Video demonstration

[Upload media here]

Logs

Logs

3.32

00:02 +0: prints default-flavor                                                                                                                              
null
00:02 +1: All tests passed!    

3.29.3

00:04 +0: prints default-flavor                                                                                                                              
dev
00:04 +1: All tests passed!    

Flutter Doctor output

Doctor output
[✓] Flutter (Channel stable, 3.32.0, on macOS 15.4.1 24E263 darwin-arm64, locale en-GB) [556ms]
    • Flutter version 3.32.0 on channel stable at /Users/alex/workspace/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision be698c48a6 (24 hours ago), 2025-05-19 12:59:14 -0700
    • Engine revision 1881800949
    • Dart version 3.8.0
    • DevTools version 2.45.1

[✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0) [1,836ms]
    • Android SDK at /Users/alex/Library/Android/sdk
    • Platform android-35, build-tools 34.0.0
    • ANDROID_HOME = /Users/alex/Library/Android/sdk
    • Java binary at: /Applications/Android Studio.app/Contents/jbr/Contents/Home/bin/java
      This is the JDK bundled with the latest Android Studio installation on this machine.
      To manually set the JDK path, use: `flutter config --jdk-dir="path/to/jdk"`.
    • Java version OpenJDK Runtime Environment (build 21.0.3+-79915917-b509.11)
    • All Android licenses accepted.

[!] Xcode - develop for iOS and macOS (Xcode 16.3) [1,087ms]
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Build 16E140
    ! CocoaPods 1.13.0 out of date (1.16.2 is recommended).
        CocoaPods is a package manager for iOS or macOS platform code.
        Without CocoaPods, plugins will not work on iOS or macOS.
        For more info, see https://flutter.dev/to/platform-plugins
      To update CocoaPods, see https://guides.cocoapods.org/using/getting-started.html#updating-cocoapods

[✗] Chrome - develop for the web (Cannot find Chrome executable at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome) [13ms]
    ! Cannot find Chrome. Try setting CHROME_EXECUTABLE to a Chrome executable.

[✓] Android Studio (version 2024.2) [13ms]
    • 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.3+-79915917-b509.11)

[✓] VS Code (version 1.100.2) [12ms]
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.110.0

[✓] Connected device (3 available) [6.3s]
    • Alex’s iPhone (wireless) (mobile) • 00008130-001A310C0491401C            • ios          • iOS 18.5 22F76
    • iPhone 15 Pro (mobile)            • 2348BBCF-963B-412E-9D7E-258EA7E42E24 • ios          • com.apple.CoreSimulator.SimRuntime.iOS-18-4 (simulator)
    • macOS (desktop)                   • macos                                • darwin-arm64 • macOS 15.4.1 24E263 darwin-arm64

[✓] Network resources [859ms]
    • All expected network resources are available.

! Doctor found issues in 2 categories.

Metadata

Metadata

Assignees

Labels

a: tests"flutter test", flutter_test, or one of our testsc: regressionIt was better in the past than it is nowfound in release: 3.32Found to occur in 3.32found in release: 3.33Found to occur in 3.33has reproducible stepsThe issue has been confirmed reproducible and is ready to work onr: fixedIssue is closed as already fixed in a newer versionteam-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