Challenge - 5 Problems
Text Styling Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ ui_behavior
intermediate1: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))
Attempts:
2 left
💡 Hint
Look at the TextStyle properties inside the Text widget.
✗ Incorrect
The Text widget uses the TextStyle with color red and fontSize 24, so the text appears red and sized 24.
📝 Syntax
intermediate1:30remaining
Correct syntax for bold and italic text
Which option correctly styles the text to be bold and italic in Flutter?
Attempts:
2 left
💡 Hint
Check the correct property names and value types for fontWeight and fontStyle.
✗ Incorrect
fontWeight and fontStyle require enum values, not strings or wrong property names.
❓ ui_behavior
advanced2: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))
Attempts:
2 left
💡 Hint
Look at the overflow property used in the Text widget.
✗ Incorrect
TextOverflow.ellipsis cuts off overflowing text and shows ... at the end.
❓ lifecycle
advanced2: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)), ); } }
Attempts:
2 left
💡 Hint
setState triggers rebuild and updates UI with new state values.
✗ Incorrect
Calling setState causes build to rerun, updating the Text color based on the new isRed value.
🔧 Debug
expert2: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))Attempts:
2 left
💡 Hint
Check how to specify underline decoration in TextStyle.
✗ Incorrect
The decoration property requires the enum TextDecoration.underline, not a bare word 'underline'.