I am learning Flutter. I am following the beginner’s codelab and video tutorial.
I am using Colors.deepOrange
for my color scheme, as shown in the tutorial. The color in my IDE and YouTube video match pretty close:
But when I run the app (in browser, Windows, or Android emulator), the color is very dark:
This applies to other colors, such as blue and green also. I looked into it, and came across P3 support, which seems to be offered now. And since I am seeing different colors on the same monitor, I would not expedct this to be the case. But if it is relevant, I am on a Windows computer with a 5 year old monitor, and the tutorial is on a Mac.
My theme just follows the tutorial:
theme: ThemeData(
useMaterial3: true,
colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepOrange),
),
as does my card:
return Card(
color: theme.colorScheme.primary,
child: Padding(
padding: const EdgeInsets.all(20),
child: Text(
pair.asLowerCase,
style: style,
semanticsLabel: pair.asPascalCase,
),
),
I have tried everything I can think of, but can’t figure it out. Any ideas what I am doing wrong to get this blah color?
2
Answers
The Card color in Flutter using Material 3 is not only determined by the color parameters but also by its elevation and the color of the item it is drawn on, using a complicated formula. If you draw a
Container
with your deep orange color that should show as you’d expect (deep Orange). Card colors in my experience are impossible to predict and best left unset so it follows the color scheme and elevation automatically.The color you’re seeing,
#8f4c38
, is the correct primary color for a color scheme usingColors.deepOrange
as theseedColor
. This is influenced by the defaultDynamicSchemeVariant.tonalSpot
andBrightness.light
.It’s possible that the difference in color between your app and the video/codelab screenshots is due to filters or post-processing effects applied to the video or images. You can verify this by comparing the color of the DEBUG badge in the video/screenshots with the one in your running code.
Here’s an explanation of your theme setup:
The color you’re seeing is part of how Flutter’s Material 3 design system adjusts colors to be more "tonal" when using
ColorScheme.fromSeed()
. The deep orange will look different from what you may expect, but this is intended by the tonal system.If you’d like to have a more vivid color, you can try using
ColorScheme.fromSwatch()
or explicitly setting the color without using a seed:This would give you a brighter version of deep orange, closer to what you’re seeing in the tutorial. However, it won’t use the Material 3 tonal system for color variations.