Repository navigation
Closed
Labels
P2Important issues not at the top of the work listImportant issues not at the top of the work listc: crashStack traces logged to the consoleStack traces logged to the consolefound in release: 3.10Found to occur in 3.10Found to occur in 3.10found in release: 3.11Found to occur in 3.11Found to occur in 3.11frameworkflutter/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 onp: material_uimaterial_ui package in flutter/packagesmaterial_ui package in flutter/packagesr: 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 teamtriaged-designTriaged by Design Languages teamTriaged 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 Flutter project
- Inside the
MaterialApp -> ThemeDatachange thebrightnessfromBrightness.lighttoBrightness.dark - Launch the app
Expected results
The app launches correctly without issues.
Actual results
The Debug Console shows this error:
════════ Exception caught by widgets library ═══════════════════════════════════
The following assertion was thrown building MyApp(dirty):
'package:flutter/src/material/theme_data.dart': Failed assertion: line 459 pos 12: 'colorScheme?.brightness == null || brightness == null || colorScheme!.brightness == brightness': is not true.
theme_data.dart:459
The relevant error-causing widget was
MyApp
main.dart:4
When the exception was thrown, this was the stack
#2 new ThemeData
theme_data.dart:459
#3 MyApp.build
main.dart:14
#4 StatelessElement.build
framework.dart:5156
#5 ComponentElement.performRebuild
framework.dart:5086
#6 Element.rebuild
framework.dart:4805
#7 BuildOwner.buildScope
framework.dart:2780
#8 WidgetsBinding.drawFrame
binding.dart:903
#9 RendererBinding._handlePersistentFrameCallback
binding.dart:358
#10 SchedulerBinding._invokeFrameCallback
binding.dart:1284
#11 SchedulerBinding.handleDrawFrame
binding.dart:1214
#12 SchedulerBinding.scheduleWarmUpFrame.<anonymous closure>
binding.dart:939
#16 _RawReceivePort._handleMessage (dart:isolate-patch/isolate_patch.dart:189:12)Code sample
This code works:
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),
useMaterial3: true,
brightness: Brightness.light,
),
home: Container(),
);
}
}This code does NOT work:
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),
useMaterial3: true,
brightness: Brightness.dark,
),
home: Container(),
);
}
}This code works:
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(
colorSchemeSeed: Colors.deepPurple,
useMaterial3: true,
brightness: Brightness.light,
),
home: Container(),
);
}
}This code works:
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(
colorSchemeSeed: Colors.deepPurple,
useMaterial3: true,
brightness: Brightness.dark,
),
home: Container(),
);
}
}Issue
- If I use
colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple)It works only withbrightness: Brightness.lightbut not withbrightness: Brightness.dark - If I use
colorSchemeSeed: Colors.deepPurpleIt works with bothbrightness: Brightness.lightandbrightness: Brightness.dark
Flutter Doctor output
[✓] Flutter (Channel stable, 3.10.1, on Fedora Linux 37 (KDE Plasma) 6.2.15-200.fc37.x86_64, locale it_IT.UTF-8)
• Flutter version 3.10.1 on channel stable at /home/alberto/tools/flutter
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision d3d8effc68 (8 giorni fa), 2023-05-16 17:59:05 -0700
• Engine revision b4fb11214d
• Dart version 3.0.1
• DevTools version 2.23.1
[✓] Android toolchain - develop for Android devices (Android SDK version 33.0.2)
• Android SDK at /home/alberto/Android/Sdk
• Platform android-33-ext4, build-tools 33.0.2
• Java binary at: /home/alberto/.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_EXECUTABLE = /opt/brave.com/brave/brave-browser
[✓] Linux toolchain - develop for Linux desktop
• clang version 15.0.7 (Fedora 15.0.7-2.fc37)
• cmake version 3.26.4
• ninja version 1.10.2
• pkg-config version 1.8.0
[✓] Android Studio (version 2022.2)
• Android Studio at /home/alberto/.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
• Java version OpenJDK Runtime Environment (build 17.0.6+0-17.0.6b802.4-9586694)
[✓] IntelliJ IDEA Community Edition (version 2023.1)
• IntelliJ at /home/alberto/.local/share/JetBrains/Toolbox/apps/IDEA-C/ch-0/231.8770.65
• 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
[✓] VS Code (version 1.78.2)
• VS Code at /usr/share/code
• Flutter extension version 3.64.0
[✓] Connected device (2 available)
• Linux (desktop) • linux • linux-x64 • Fedora Linux 37 (KDE Plasma) 6.2.15-200.fc37.x86_64
• Chrome (web) • chrome • web-javascript • Brave Browser 113.1.51.118
[✓] Network resources
• All expected network resources are available.
• No issues found!Metadata
Metadata
Assignees
Labels
P2Important issues not at the top of the work listImportant issues not at the top of the work listc: crashStack traces logged to the consoleStack traces logged to the consolefound in release: 3.10Found to occur in 3.10Found to occur in 3.10found in release: 3.11Found to occur in 3.11Found to occur in 3.11frameworkflutter/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 onp: material_uimaterial_ui package in flutter/packagesmaterial_ui package in flutter/packagesr: 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 teamtriaged-designTriaged by Design Languages teamTriaged by Design Languages team
Type
Projects
- StatusShow more project fieldsDone (PR merged)
Activity
huycozy commentedon May 25, 2023
Thanks for your report. This issue is reproducible on the latest
stableandmasterchannels.For more information about the last condition from the failed assertion (
colorScheme!.brightness == brightness):flutter/packages/flutter/lib/src/material/color_scheme.dart
Line 160 in 54d001d
It is in conflict with
brightness: Brightness.darkfromThemeData.flutter doctor -v (stable and master)
[✓] Flutter (Channel stable, 3.10.2, on macOS 13.0.1 22A400 darwin-x64, locale en-VN) • Flutter version 3.10.2 on channel stable at /Users/huynq/Documents/GitHub/flutter • Upstream repository https://github.com/flutter/flutter.git • Framework revision 9cd3d0d9ff (22 hours ago), 2023-05-23 20:57:28 -0700 • Engine revision 90fa3ae28f • Dart version 3.0.2 • DevTools version 2.23.1 [✓] Android toolchain - develop for Android devices (Android SDK version 32.0.0) • Android SDK at /Users/huynq/Library/Android/sdk • Platform android-33, build-tools 32.0.0 • ANDROID_HOME = /Users/huynq/Library/Android/sdk • Java binary at: /Applications/Android Studio.app/Contents/jbr/Contents/Home/bin/java • Java version OpenJDK Runtime Environment (build 17.0.6+0-17.0.6b802.4-9586694) • All Android licenses accepted. [✓] Xcode - develop for iOS and macOS (Xcode 14.3) • Xcode at /Applications/Xcode.app/Contents/Developer • Build 14E222b • CocoaPods version 1.11.3 [✓] Chrome - develop for the web • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome [✓] Android Studio (version 2022.2) • 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 17.0.6+0-17.0.6b802.4-9586694) [✓] VS Code (version 1.78.1) • VS Code at /Applications/Visual Studio Code.app/Contents • Flutter extension version 3.64.0 [✓] Connected device (3 available) • RMX2001 (mobile) • EUYTFEUSQSRGDA6D • android-arm64 • Android 11 (API 30) • macOS (desktop) • macos • darwin-x64 • macOS 13.0.1 22A400 darwin-x64 • Chrome (web) • chrome • web-javascript • Google Chrome 113.0.5672.126 [✓] Network resources • All expected network resources are available. • No issues found!HansMuller commentedon May 31, 2023
@huycozy is correct. To correct a dark color scheme (dark theme) you need to override the color scheme's brightness parameter:
flutter-triage-bot commentedon Oct 18, 2023
This issue is assigned to @HansMuller but has had no recent status updates. Please consider unassigning this issue if it is not going to be addressed in the near future. This allows people to have a clearer picture of what work is actually planned. Thanks!
Provide a helpful error message when `ColorScheme.brightness` doesn't…
github-actions commentedon Nov 20, 2023
This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of
flutter doctor -vand a minimal reproduction of the issue.