Challenge - 5 Problems
Widget Tree Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ ui_behavior
intermediateUnderstanding Widget Tree Rendering
Given the Flutter widget tree below, what will be the color of the text displayed on the screen?
Flutter
MaterialApp(
home: Scaffold(
body: Container(
color: Colors.blue,
child: Center(
child: Text('Hello', style: TextStyle(color: Colors.white)),
),
),
),
)Attempts:
2 left
💡 Hint
Look at the Container's color and the TextStyle color.
✗ Incorrect
The Container sets the background color to blue. The Text widget has its color set to white, so the text appears white on blue.
intermediate
Widget Tree and Navigation Stack
In a Flutter app, if you push a new route onto the Navigator stack, how does it affect the widget tree?
Attempts:
2 left
💡 Hint
Think about how Flutter shows new screens without losing the old ones.
✗ Incorrect
When a new route is pushed, Flutter adds a new widget subtree on top of the existing tree to represent the new screen, preserving the previous routes below.
❓ lifecycle
advancedWidget Tree and State Lifecycle
Which lifecycle method is called when a StatefulWidget is removed from the widget tree permanently?
Attempts:
2 left
💡 Hint
This method is used to clean up resources.
✗ Incorrect
The dispose() method is called when the StatefulWidget is permanently removed from the widget tree to release resources.
📝 Syntax
advancedCorrect Widget Tree Syntax
Which of the following Flutter widget trees is syntactically correct?
Attempts:
2 left
💡 Hint
Check the property name and value types for Column.
✗ Incorrect
The Column widget expects a 'children' property with a list of widgets. Option B uses the correct syntax.
🔧 Debug
expertDiagnosing Widget Tree Build Errors
You have this widget tree snippet:
Container(
child: Text('Hello'),
color: Colors.red,
child: Icon(Icons.star),
)
What error will this cause?
Attempts:
2 left
💡 Hint
Check the Container properties carefully.
✗ Incorrect
A widget property cannot be specified twice. Having two 'child' properties causes a syntax error.
