-
Notifications
You must be signed in to change notification settings - Fork 28.9k
Open
Labels
a: buildBuilding flutter applications with the toolBuilding flutter applications with the toolc: regressionIt was better in the past than it is nowIt was better in the past than it is nowfound in release: 3.32Found to occur in 3.32Found to occur in 3.32found in release: 3.33Found to occur in 3.33Found to occur in 3.33has reproducible stepsThe issue has been confirmed reproducible and is ready to work onThe issue has been confirmed reproducible and is ready to work onplatform-androidAndroid applications specificallyAndroid applications specificallyteam-toolOwned by Flutter Tool teamOwned by Flutter Tool teamtoolAffects the "flutter" command-line tool. See also t: labels.Affects the "flutter" command-line tool. See also t: labels.
Description
Steps to reproduce
- Setup the Flutter version to be 3.32.6 (every 3.26 version has that bug)
- Create a basic android app with 2 flavors "staging" and "production"
- Add some code that is specifically for those flavors. For example "StagingPage" and "ProdPage"
- Include one or the other widget by using
Env.isStaging ? StagingPage() : ProdPage()
(full code example below) - Build a release version of the app using --code-size-directory. E.g.
fvm flutter build apk --release --analyze-size --code-size-directory=./flutter_3.32.6/ --flavor staging --target-platform=android-arm64
- Check the output trace and search for the class or file that should have been removed
- File/class can be found in trace. In this example the file
package:demo_project/prod_code/prod_page.dart
can be found - Change the flutter version to 3.29.3
- Build again using the command from step 5 (adjusted the output folder)
fvm flutter build apk --release --analyze-size --code-size-directory=./flutter_3.29.3/ --flavor staging --target-platform=android-arm64
- File/class cannot be found in trace. This is correct.
One more info: When running an iOS build using --code-size-directory
the trace does not contain the file/class which is correct. This problem only happens on android.
ℹ️ I assume that the creation of the trace is incorrect, the final output of the app is correct.
Expected results
I expect the other class and file to be removed and not be part of the trace depending on my flavor
Actual results
The file and class is in the trace
Code sample
Code sample
main.dart
import 'package:demo_project/prod_code/prod_page.dart';
import 'package:demo_project/test_code/staging_page.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
class Env {
static const isStaging = appFlavor == "staging" || appFlavor == "Staging";
}
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
theme: ThemeData(
colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
),
home: const MyHomePage(title: 'Flutter Demo Home Page'),
);
}
}
class MyHomePage extends StatefulWidget {
const MyHomePage({super.key, required this.title});
final String title;
@override
State<MyHomePage> createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
backgroundColor: Theme.of(context).colorScheme.inversePrimary,
title: Text(widget.title),
),
body: Center(
child: FloatingActionButton(
onPressed: () => navigateToNextPage(),
tooltip: 'Increment',
child: const Icon(Icons.add),
),
),
);
}
void navigateToNextPage() {
Navigator.of(context).push(
MaterialPageRoute(
builder: (context) {
return Env.isStaging ? StagingPage() : ProdPage();
},
),
);
}
}
test_code/staging_page.dart
import 'package:flutter/cupertino.dart';
class StagingPage extends StatefulWidget {
const StagingPage({super.key});
@override
State<StagingPage> createState() => _StagingPageState();
}
class _StagingPageState extends State<StagingPage> {
@override
Widget build(BuildContext context) {
return const Placeholder();
}
}
prod_code/prod_page.dart
import 'package:flutter/cupertino.dart';
class ProdPage extends StatelessWidget {
const ProdPage({super.key});
@override
Widget build(BuildContext context) {
return const Placeholder();
}
}
pubspec.yaml (default flutter project)
name: demo_project
description: "A new Flutter project."
# The following line prevents the package from being accidentally published to
# pub.dev using `flutter pub publish`. This is preferred for private packages.
publish_to: 'none' # Remove this line if you wish to publish to pub.dev
# The following defines the version and build number for your application.
# A version number is three numbers separated by dots, like 1.2.43
# followed by an optional build number separated by a +.
# Both the version and the builder number may be overridden in flutter
# build by specifying --build-name and --build-number, respectively.
# In Android, build-name is used as versionName while build-number used as versionCode.
# Read more about Android versioning at https://developer.android.com/studio/publish/versioning
# In iOS, build-name is used as CFBundleShortVersionString while build-number is used as CFBundleVersion.
# Read more about iOS versioning at
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
# In Windows, build-name is used as the major, minor, and patch parts
# of the product and file versions while build-number is used as the build suffix.
version: 1.0.0+1
environment:
sdk: ^3.7.2
# Dependencies specify other packages that your package needs in order to work.
# To automatically upgrade your package dependencies to the latest versions
# consider running `flutter pub upgrade --major-versions`. Alternatively,
# dependencies can be manually updated by changing the version numbers below to
# the latest version available on pub.dev. To see which dependencies have newer
# versions available, run `flutter pub outdated`.
dependencies:
flutter:
sdk: flutter
# The following adds the Cupertino Icons font to your application.
# Use with the CupertinoIcons class for iOS style icons.
cupertino_icons: ^1.0.8
dev_dependencies:
flutter_test:
sdk: flutter
# The "flutter_lints" package below contains a set of recommended lints to
# encourage good coding practices. The lint set provided by the package is
# activated in the `analysis_options.yaml` file located at the root of your
# package. See that file for information about deactivating specific lint
# rules and activating additional ones.
flutter_lints: ^5.0.0
# For information on the generic Dart part of this file, see the
# following page: https://dart.dev/tools/pub/pubspec
# The following section is specific to Flutter packages.
flutter:
# The following line ensures that the Material Icons font is
# included with your application, so that you can use the icons in
# the material Icons class.
uses-material-design: true
# To add assets to your application, add an assets section, like this:
# assets:
# - images/a_dot_burr.jpeg
# - images/a_dot_ham.jpeg
# An image asset can refer to one or more resolution-specific "variants", see
# https://flutter.dev/to/resolution-aware-images
# For details regarding adding assets from package dependencies, see
# https://flutter.dev/to/asset-from-package
# To add custom fonts to your application, add a fonts section here,
# in this "flutter" section. Each entry in this list should have a
# "family" key with the font family name, and a "fonts" key with a
# list giving the asset and other descriptors for the font. For
# example:
# fonts:
# - family: Schyler
# fonts:
# - asset: fonts/Schyler-Regular.ttf
# - asset: fonts/Schyler-Italic.ttf
# style: italic
# - family: Trajan Pro
# fonts:
# - asset: fonts/TrajanPro.ttf
# - asset: fonts/TrajanPro_Bold.ttf
# weight: 700
#
# For details regarding fonts from package dependencies,
# see https://flutter.dev/to/font-from-package
Screenshots or Video
Example of the trace demonstration
Part of the incorrect trace build with flutter 3.32.6 and flavor staging (should not contain prod code) "Scaffold",
"package:flutter/src/widgets/icon.dart",
"Icon",
"package:flutter/src/widgets/icon_data.dart",
"IconData",
"build.<anonymous closure @1214>",
"Clip",
"_FloatingActionButtonType",
"package:flutter/src/painting/alignment.dart",
"Alignment",
"AlignmentGeometry",
"navigateToNextPage",
"Navigator",
"navigateToNextPage.<anonymous closure @1450>",
"package:demo_project/prod_code/prod_page.dart",
"ProdPage",
"_RouteEntry",
"RouteTransitionRecord",
"new _RouteEntry@70124995.",
"_pushEntry@70124995",
"_RouteLifecycle",
"_History",
"_flushHistoryUpdates@70124995",
"_cancelActivePointers@70124995",
"cancelPointer",
Part of the correct trace build with flutter 3.32.6 and flavor staging (should not contain prod code)
"autofocus",
"_markPropertiesChanged@49042876",
"package:flutter/src/widgets/text.dart",
"Text",
"AppBar",
"new AppBar.",
"FloatingActionButton",
"Center",
"Align",
"Scaffold",
"package:flutter/src/widgets/icon.dart",
"Icon",
"package:flutter/src/widgets/icon_data.dart",
"IconData",
"build.<anonymous closure @1214>",
"Clip",
"package:flutter/src/painting/alignment.dart",
"Alignment",
"AlignmentGeometry",
"navigateToNextPage",
"Navigator",
"navigateToNextPage.<anonymous closure @1450>",
"package:demo_project/test_code/staging_page.dart",
"StagingPage",
"_RouteEntry",
"RouteTransitionRecord",
"new _RouteEntry@70124995.",
"_pushEntry@70124995",
"_RouteLifecycle",
"_History",
"_flushHistoryUpdates@70124995",
"_cancelActivePointers@70124995",
"cancelPointer",
"_cancelActivePointers@70124995.<anonymous closure @220581>",
"_overlayKey@70124995",
"set:absorbing",
Logs
Flutter Doctor output
Doctor output
fvm flutter doctor --verbose
[✓] Flutter (Channel stable, 3.29.3, on macOS 15.5 24F74 darwin-arm64, locale en-US) [1,814ms]
• Flutter version 3.29.3 on channel stable at /Users/julianbissekkou/fvm/versions/3.29.3
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision ea121f8859 (3 months ago), 2025-04-11 19:10:07 +0000
• Engine revision cf56914b32
• Dart version 3.7.2
• DevTools version 2.42.3
[✓] Android toolchain - develop for Android devices (Android SDK version 35.0.0) [2.2s]
• Android SDK at /Users/julianbissekkou/Library/Android/sdk
• Platform android-35, build-tools 35.0.0
• Java binary at: /Users/julianbissekkou/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.6+-13368085-b895.109)
• All Android licenses accepted.
[✓] Xcode - develop for iOS and macOS (Xcode 16.3) [1,581ms]
• Xcode at /Applications/Xcode.app/Contents/Developer
• Build 16E140
• CocoaPods version 1.16.2
[✓] Chrome - develop for the web [220ms]
• Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
[✓] Android Studio (version 2024.3) [220ms]
• Android Studio at /Users/julianbissekkou/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+-13368085-b895.109)
[✓] IntelliJ IDEA Community Edition (version 2025.1.1.1) [218ms]
• IntelliJ at /Users/julianbissekkou/Applications/IntelliJ IDEA Community Edition.app
• Flutter plugin version 85.3.2
• Dart plugin version 251.25410.28
[✓] VS Code (version 1.101.2) [10ms]
• VS Code at /Applications/Visual Studio Code.app/Contents
• Flutter extension version 3.114.0
[✓] Connected device (5 available) [7.3s]
• sdk gphone64 arm64 (mobile) • emulator-5554 • android-arm64 • Android 14 (API 34) (emulator)
• iPhone von Julian (wireless) (mobile) • 00008130-001C6C221AE0001C • ios • iOS 18.5 22F76
• macOS (desktop) • macos • darwin-arm64 • macOS 15.5 24F74 darwin-arm64
• Mac Designed for iPad (desktop) • mac-designed-for-ipad • darwin • macOS 15.5 24F74 darwin-arm64
• Chrome (web) • chrome • web-javascript • Google Chrome 138.0.7204.101
! Error: Browsing on the local area network for Julian’s Apple Watch. Ensure the device is unlocked and discoverable via Bluetooth.
(code -27)
[✓] Network resources [701ms]
• All expected network resources are available.
• No issues found!
stefanschaller, sbergmair and TarekTolba1
Metadata
Metadata
Assignees
Labels
a: buildBuilding flutter applications with the toolBuilding flutter applications with the toolc: regressionIt was better in the past than it is nowIt was better in the past than it is nowfound in release: 3.32Found to occur in 3.32Found to occur in 3.32found in release: 3.33Found to occur in 3.33Found to occur in 3.33has reproducible stepsThe issue has been confirmed reproducible and is ready to work onThe issue has been confirmed reproducible and is ready to work onplatform-androidAndroid applications specificallyAndroid applications specificallyteam-toolOwned by Flutter Tool teamOwned by Flutter Tool teamtoolAffects the "flutter" command-line tool. See also t: labels.Affects the "flutter" command-line tool. See also t: labels.