-
Notifications
You must be signed in to change notification settings - Fork 30.1k
Closed
Labels
customer: crowdAffects or could affect many people, though not necessarily a specific customer.Affects or could affect many people, though not necessarily a specific customer.f: material designflutter/packages/flutter/material repository.flutter/packages/flutter/material repository.found in release: 3.10Found to occur in 3.10Found to occur in 3.10found in release: 3.13Found to occur in 3.13Found to occur in 3.13frameworkflutter/packages/flutter repository. See also f: labels.flutter/packages/flutter repository. See also f: labels.has reproducible stepsThe issue has been confirmed reproducible and is ready to work onThe issue has been confirmed reproducible and is ready to work onr: fixedIssue is closed as already fixed in a newer versionIssue is closed as already fixed in a newer versionteam-designOwned by Design Languages teamOwned by Design Languages team
Description
Is there an existing issue for this?
- I have searched the existing issues
- I have read the guide to filing a bug
Steps to reproduce
- Create a new empty
MaterialAppwithScaffoldandAppBar. - Set
foregroundColortoColors.black87in light theme, orColors.whitein dark theme. (Those are thekDefaultIconLightColorandkDefaultIconDarkColor). - Set
ThemeDatawithuseMaterial3: true. - Add some leading or actions to AppBar. For example:
leading: IconButton(icon: const Icon(Icons.menu), onPressed: () {}),
Expected results
When we set foregroundColor or iconTheme in AppBar to Colors.black87 in Light mode, or Colors.white in Dark mode, this color should be used for leading and action buttons.
Actual results
foregroundColor or iconTheme set in AppBar is ignored, and the default ColorScheme onSurfaceVariant color is used instead.
Code sample
Code sample
This is code for a simple app to test the issue:import 'package:flutter/material.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
@override
Widget build(BuildContext context) {
return MaterialApp(
theme: ThemeData(
colorScheme: const ColorScheme.dark().copyWith(onSurfaceVariant: Colors.red),
useMaterial3: true,
),
home: Scaffold(
appBar: AppBar(
foregroundColor: Colors.white, // This color is ignored and icons are red!
iconTheme: const IconThemeData(color: Colors.white), // This color is also ignored and icons are red!
leading: IconButton(icon: const Icon(Icons.menu), onPressed: () {}),
actions: <Widget>[
IconButton(icon: const Icon(Icons.add), onPressed: () {}),
],
),
),
);
}
}Test
This is slightly edited code from app_bar_test.dart. This test will fail with Colors.black87, but is successful with any other color.
testWidgets('The foregroundColor property of the AppBar overrides any IconButtonTheme present in the theme - M3', (WidgetTester tester) async {
final ThemeData themeData = ThemeData(useMaterial3: true);
await tester.pumpWidget(
MaterialApp(
theme: themeData,
home: Scaffold(
appBar: AppBar(
foregroundColor: Colors.black87,
leading: IconButton(icon: const Icon(Icons.menu), onPressed: () {}),
actions: <Widget>[
IconButton(icon: const Icon(Icons.add), onPressed: () {}),
],
),
),
),
);
Color? leadingIconButtonColor() => iconStyle(tester, Icons.menu)?.color;
Color? actionIconButtonColor() => iconStyle(tester, Icons.add)?.color;
expect(leadingIconButtonColor(), Colors.black87);
expect(actionIconButtonColor(), Colors.black87);
});Screenshots or Video
Screenshots / Video demonstration
Logs
No response
Flutter Doctor output
Doctor output
[✓] Flutter (Channel master, 3.13.0-3.0.pre.21, on Linux Mint 21.1 5.19.0-46-generic, locale cs_CZ.UTF-8)
• Flutter version 3.13.0-3.0.pre.21 on channel master at /home/helu/Software/flutter
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision 47ba59c762 (8 hours ago), 2023-07-12 20:46:57 -0400
• Engine revision 1b1ccdd1f5
• Dart version 3.1.0 (build 3.1.0-302.0.dev)
• DevTools version 2.25.0
[✓] Android toolchain - develop for Android devices (Android SDK version 33.0.0)
• Android SDK at /home/helu/Software/android-sdk
• Platform android-33, build-tools 33.0.0
• ANDROID_HOME = /home/helu/Software/android-sdk/
• Java binary at: /home/helu/.local/share/JetBrains/Toolbox/apps/AndroidStudio/ch-0/222.4459.24.2221.9971841/jbr/bin/java
• Java version OpenJDK Runtime Environment (build 17.0.6+0-17.0.6b802.4-9586694)
• All Android licenses accepted.
[✓] Chrome - develop for the web
• Chrome at google-chrome
[✓] Linux toolchain - develop for Linux desktop
• Ubuntu clang version 14.0.0-1ubuntu1
• cmake version 3.22.1
• ninja version 1.10.1
• pkg-config version 0.29.2
[✓] Android Studio (version 2022.2)
• Android Studio at /home/helu/.local/share/JetBrains/Toolbox/apps/AndroidStudio/ch-0/222.4459.24.2221.10121639
• 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 17.0.6+0-17.0.6b802.4-9586694)
[!] Android Studio (version unknown)
• Android Studio at /home/helu/.local/share/JetBrains/Toolbox/apps/AndroidStudio/ch-0/222.4459.24.2221.9971841
• 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
✗ Unable to determine Android Studio version.
• android-studio-dir = /home/helu/.local/share/JetBrains/Toolbox/apps/AndroidStudio/ch-0/222.4459.24.2221.9971841
• Java version OpenJDK Runtime Environment (build 17.0.6+0-17.0.6b802.4-9586694)
[✓] VS Code (version 1.80.0)
• VS Code at /usr/share/code
• Flutter extension version 3.68.0
[✓] Connected device (3 available)
• sdk gphone64 x86 64 (mobile) • emulator-5554 • android-x64 • Android 13 (API 33) (emulator)
• Linux (desktop) • linux • linux-x64 • Linux Mint 21.1 5.19.0-46-generic
• Chrome (web) • chrome • web-javascript • Google Chrome 114.0.5735.198
! Device R3CT30WFRLD is not authorized.
You might need to check your device for an authorization dialog.
[✓] Network resources
• All expected network resources are available.
! Doctor found issues in 1 category.```
</details>Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
customer: crowdAffects or could affect many people, though not necessarily a specific customer.Affects or could affect many people, though not necessarily a specific customer.f: material designflutter/packages/flutter/material repository.flutter/packages/flutter/material repository.found in release: 3.10Found to occur in 3.10Found to occur in 3.10found in release: 3.13Found to occur in 3.13Found to occur in 3.13frameworkflutter/packages/flutter repository. See also f: labels.flutter/packages/flutter repository. See also f: labels.has reproducible stepsThe issue has been confirmed reproducible and is ready to work onThe issue has been confirmed reproducible and is ready to work onr: fixedIssue is closed as already fixed in a newer versionIssue is closed as already fixed in a newer versionteam-designOwned by Design Languages teamOwned by Design Languages team
Type
Projects
Status
Done (PR merged)


