Challenge - 5 Problems
ThemeData Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ ui_behavior
intermediate2:00remaining
What color will the AppBar background be?
Given this Flutter ThemeData configuration, what color will the AppBar background show?
Flutter
ThemeData(
primaryColor: Colors.green,
appBarTheme: AppBarTheme(
backgroundColor: Colors.red,
),
)Attempts:
2 left
💡 Hint
AppBarTheme backgroundColor overrides primaryColor for AppBar.
✗ Incorrect
The AppBarTheme's backgroundColor property sets the AppBar color, overriding primaryColor.
📝 Syntax
intermediate2:00remaining
Identify the syntax error in ThemeData usage
Which option contains a syntax error in ThemeData configuration?
Attempts:
2 left
💡 Hint
Check for missing colons between property names and values.
✗ Incorrect
Option C is missing a colon after primaryColor, causing a syntax error.
❓ lifecycle
advanced2:00remaining
When does ThemeData update take effect in Flutter?
If you change ThemeData in a Flutter app's MaterialApp dynamically, when will the new theme apply?
Attempts:
2 left
💡 Hint
ThemeData is part of widget tree and rebuilds with setState.
✗ Incorrect
Changing ThemeData inside MaterialApp and calling setState causes immediate UI rebuild with new theme.
🔧 Debug
advanced2:00remaining
Why does the Text color not change with ThemeData?
You set ThemeData with primaryColor: Colors.red and textTheme with bodyText1 color blue, but Text widgets still show black. Why?
Flutter
ThemeData(
primaryColor: Colors.red,
textTheme: TextTheme(
bodyText1: TextStyle(color: Colors.blue),
),
)
// Text widget:
Text('Hello World')Attempts:
2 left
💡 Hint
Text widget uses default style unless told to use theme style.
✗ Incorrect
Text widgets do not automatically use textTheme.bodyText1 unless style is set to Theme.of(context).textTheme.bodyText1.
🧠 Conceptual
expert2:00remaining
What is the effect of brightness in ThemeData?
What does setting brightness: Brightness.dark in ThemeData do in a Flutter app?
Attempts:
2 left
💡 Hint
Brightness controls overall light or dark theme mode.
✗ Incorrect
Brightness.dark sets the app to dark mode, changing default colors of widgets to suit dark backgrounds.