0
0
Fluttermobile~20 mins

Text themes in Flutter - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Text Theme Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
ui_behavior
intermediate
2:00remaining
What is the output of this Flutter code snippet?

Consider this Flutter widget that uses a text theme:

Text(
  'Hello Flutter',
  style: Theme.of(context).textTheme.headlineMedium,
)

What style will the text have if the app's theme sets headlineMedium to 24px font size and blue color?

Flutter
Text('Hello Flutter', style: Theme.of(context).textTheme.headlineMedium)
AText with 24px font size but default color
BText with default font size and black color
CText with 24px font size and blue color
DText with default font size but blue color
Attempts:
2 left
💡 Hint

TextTheme styles override default text styles when applied.

🧠 Conceptual
intermediate
1:30remaining
Which statement about Flutter TextTheme is true?

Choose the correct statement about TextTheme in Flutter.

A<code>TextTheme</code> defines default text styles for different text categories like headline, body, label.
B<code>TextTheme</code> is used only for button text styling.
C<code>TextTheme</code> cannot be customized by the app developer.
D<code>TextTheme</code> styles override widget-specific styles always.
Attempts:
2 left
💡 Hint

Think about what TextTheme controls in an app's look.

📝 Syntax
advanced
2:00remaining
What error does this Flutter code produce?

Analyze this Flutter code snippet:

Text(
  'Welcome',
  style: Theme.of(context).textTheme.headlineLarge.copyWith(fontWeight: FontWeight.bold),
)

What error will occur when running this code?

Flutter
Text('Welcome', style: Theme.of(context).textTheme.headlineLarge.copyWith(fontWeight: FontWeight.bold))
ATypeError because copyWith is not a method
BNo error, text is bold with headlineLarge style
CSyntax error due to missing semicolon
DNullPointerException because headlineLarge might be null
Attempts:
2 left
💡 Hint

Consider if headlineLarge can be null in some themes.

lifecycle
advanced
2:00remaining
When does Flutter apply updated TextTheme styles after a theme change?

If the app's ThemeData changes at runtime, when will widgets using Theme.of(context).textTheme update their text styles?

AImmediately on the next frame after theme change
BOnly after restarting the app
CAfter hot reload but not on hot restart
DNever, text styles are fixed at build time
Attempts:
2 left
💡 Hint

Think about Flutter's reactive UI system and how it rebuilds widgets.

🔧 Debug
expert
2:30remaining
Why does this Flutter app show default black text ignoring custom TextTheme?

Given this Flutter app snippet:

MaterialApp(
  theme: ThemeData(
    textTheme: TextTheme(
      bodyMedium: TextStyle(color: Colors.red),
    ),
  ),
  home: Scaffold(
    body: Center(
      child: Text('Hello'),
    ),
  ),
)

Why does the text appear black instead of red?

ABecause <code>Text</code> widget ignores theme styles unless explicitly set
BBecause <code>Text</code> uses <code>bodyText2</code> by default, not <code>bodyMedium</code>
CBecause <code>TextStyle</code> color must be set in <code>primaryTextTheme</code> not <code>textTheme</code>
DBecause <code>Colors.red</code> is not a valid color constant
Attempts:
2 left
💡 Hint

Check the default text style used by Text widget.