Challenge - 5 Problems
Color Scheme Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ ui_behavior
intermediate1:30remaining
What color will the text display?
Given this Flutter code snippet, what color will the text "Hello" appear on the screen?
Flutter
MaterialApp(
theme: ThemeData(
colorScheme: ColorScheme.fromSeed(seedColor: Colors.blue),
),
home: Scaffold(
body: Builder(
builder: (context) => Center(
child: Text('Hello', style: TextStyle(color: Theme.of(context).colorScheme.primary)),
),
),
),
)Attempts:
2 left
💡 Hint
The colorScheme.primary uses the seed color to generate its primary color.
✗ Incorrect
The ColorScheme.fromSeed creates a color scheme based on the seed color blue. The primary color in the scheme is a shade of blue derived from that seed.
🧠 Conceptual
intermediate1:00remaining
What does ColorScheme.brightness control?
In Flutter's ColorScheme, what is the role of the brightness property?
Attempts:
2 left
💡 Hint
Think about how apps switch between light and dark modes.
✗ Incorrect
The brightness property tells Flutter if the color scheme is light or dark, which influences default background and text colors for readability.
📝 Syntax
advanced1:30remaining
Which code correctly creates a dark ColorScheme with a custom primary color?
Select the Flutter code snippet that correctly creates a dark ColorScheme with a primary color of deep purple.
Attempts:
2 left
💡 Hint
Check the exact property name used in ColorScheme.
✗ Incorrect
The correct property name is 'primary'. 'primaryColor' is not valid in ColorScheme constructor. Color.deepPurple is invalid; Colors.deepPurple is correct.
❓ lifecycle
advanced1:30remaining
When does Flutter apply a new ColorScheme after theme change?
If you update the ColorScheme in ThemeData dynamically, when does Flutter apply the new colors to the UI?
Attempts:
2 left
💡 Hint
Think about how Flutter rebuilds widgets after state changes.
✗ Incorrect
Flutter applies theme changes immediately on the next frame after setState triggers a rebuild, updating UI colors dynamically.
🔧 Debug
expert2:00remaining
Why does this app show default colors ignoring custom ColorScheme?
This Flutter app uses ThemeData with a custom ColorScheme, but the UI still shows default colors. What is the most likely cause?
Flutter
MaterialApp(
theme: ThemeData(
colorScheme: ColorScheme.light(primary: Colors.orange),
),
home: Scaffold(
appBar: AppBar(title: Text('Test')),
body: Center(child: Text('Hello')),
),
)Attempts:
2 left
💡 Hint
Check how AppBar gets its colors from the theme.
✗ Incorrect
AppBar uses the primaryColor from ThemeData by default, not the colorScheme.primary. To use colorScheme colors, you must set useMaterial3: true or customize AppBarTheme.