0
0
Fluttermobile~20 mins

Text widget and styling in Flutter - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Text Styling Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
ui_behavior
intermediate
1:30remaining
Text widget color and font size
What will be the color and font size of the text displayed by this Flutter code?
Flutter
Text('Hello Flutter', style: TextStyle(color: Colors.red, fontSize: 24))
AText is black with font size 24
BText is red with default font size
CText is red with font size 24
DText is black with default font size
Attempts:
2 left
💡 Hint
Look at the TextStyle properties inside the Text widget.
📝 Syntax
intermediate
1:30remaining
Correct syntax for bold and italic text
Which option correctly styles the text to be bold and italic in Flutter?
AText('Bold Italic', style: TextStyle(fontWeight: FontWeight.bold, fontStyle: FontStyle.italic))
BText('Bold Italic', style: TextStyle(weight: FontWeight.bold, style: FontStyle.italic))
CText('Bold Italic', style: TextStyle(fontWeight: 'bold', fontStyle: 'italic'))
DText('Bold Italic', style: TextStyle(fontWeight: FontWeight.bold, fontStyle: 'italic'))
Attempts:
2 left
💡 Hint
Check the correct property names and value types for fontWeight and fontStyle.
ui_behavior
advanced
2:00remaining
Text overflow behavior
What happens when this Flutter Text widget is displayed in a narrow container?
Flutter
Container(width: 100, child: Text('This is a very long text that might overflow', overflow: TextOverflow.ellipsis))
AText is cut off with an ellipsis (...) at the end
BText wraps to the next line
CText overflows and causes a runtime error
DText is fully shown ignoring the container width
Attempts:
2 left
💡 Hint
Look at the overflow property used in the Text widget.
lifecycle
advanced
2:00remaining
Text widget rebuild on state change
If a Text widget's style depends on a state variable, what happens when the state changes and setState() is called?
Flutter
class MyWidget extends StatefulWidget {
  @override
  State<MyWidget> createState() => _MyWidgetState();
}

class _MyWidgetState extends State<MyWidget> {
  bool isRed = true;

  @override
  Widget build(BuildContext context) {
    return GestureDetector(
      onTap: () => setState(() => isRed = !isRed),
      child: Text('Tap me', style: TextStyle(color: isRed ? Colors.red : Colors.blue)),
    );
  }
}
AText color changes but only after hot reload
BText color never changes after first build
CApp crashes due to infinite rebuild loop
DText color toggles between red and blue on each tap
Attempts:
2 left
💡 Hint
setState triggers rebuild and updates UI with new state values.
🔧 Debug
expert
2:30remaining
Why does this Text widget not show styled text?
This Flutter code tries to style text with underline and color, but the text appears normal. What is the cause?
Flutter
Text('Styled Text', style: TextStyle(decoration: TextDecoration.underline, color: Colors.green))
AText widget ignores style property by default
BThe decoration value should be TextDecoration.underline, not underline
CColors.green is not a valid color constant
DTextStyle does not support decoration property
Attempts:
2 left
💡 Hint
Check how to specify underline decoration in TextStyle.