Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to enable dark mode support in the MaterialApp widget.
Flutter
MaterialApp( title: 'My App', theme: ThemeData.light(), darkTheme: ThemeData.[1](), themeMode: ThemeMode.system, home: HomePage(), )
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using ThemeData.darkMode() which does not exist.
Using ThemeData.darkTheme() which is incorrect.
✗ Incorrect
The correct method to create a dark theme is ThemeData.dark().
2fill in blank
mediumComplete the code to set the app's theme mode to always use dark mode.
Flutter
MaterialApp(
themeMode: ThemeMode.[1],
home: HomePage(),
) Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using ThemeMode.system which follows device settings.
Using ThemeMode.light which forces light mode.
✗ Incorrect
ThemeMode.dark forces the app to always use the dark theme.
3fill in blank
hardFix the error in the code to properly detect dark mode in a widget.
Flutter
bool isDark = MediaQuery.of(context).[1] == Brightness.dark; Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using MediaQuery.of(context).brightness which does not exist.
Using 'darkMode' which is not a MediaQuery property.
✗ Incorrect
MediaQuery.of(context).platformBrightness gives the current brightness mode of the device.
4fill in blank
hardFill both blanks to create a widget that changes text color based on dark mode.
Flutter
Text( 'Hello', style: TextStyle(color: isDark ? [1] : [2]), )
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using the same color for both modes causing poor contrast.
Using colors that are hard to read on dark or light backgrounds.
✗ Incorrect
In dark mode, text color is usually white; in light mode, black.
5fill in blank
hardFill all three blanks to define a dark theme with primary color blue and scaffold background black.
Flutter
ThemeData( brightness: Brightness.[1], primaryColor: Colors.[2], scaffoldBackgroundColor: Colors.[3], )
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using Brightness.light instead of dark.
Mixing colors that do not fit dark mode design.
✗ Incorrect
Dark theme uses Brightness.dark, primary color blue, and black background for scaffold.