0
0
Fluttermobile~20 mins

SizedBox and Padding in Flutter - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
SizedBox and Padding 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 widget tree?
Consider this Flutter code snippet. What will you see on the screen?
Flutter
Column(
  children: [
    SizedBox(width: 100, height: 50, child: Container(color: Colors.red)),
    Padding(padding: EdgeInsets.all(20), child: Container(width: 50, height: 50, color: Colors.blue))
  ]
)
AA red box 100x50 pixels overlapping a blue box 50x50 pixels
BA red box 100x50 pixels, then a blue box 90x90 pixels with padding inside
COnly a red box 100x50 pixels is visible; blue box is hidden
DA red box 100x50 pixels, then a blue box 50x50 pixels with 20 pixels space around it
Attempts:
2 left
💡 Hint
Remember that Padding adds space outside its child, while SizedBox sets fixed size.
lifecycle
intermediate
1:30remaining
How does Padding affect layout during Flutter widget rebuild?
If you change the padding value dynamically in a StatefulWidget, what happens to the layout?
APadding does not change until app restart
BPadding causes a runtime error if changed dynamically
CThe widget rebuilds and the padding space updates immediately
DPadding value changes but layout stays the same
Attempts:
2 left
💡 Hint
Think about how Flutter rebuilds widgets on state change.
📝 Syntax
advanced
1:30remaining
Which option correctly uses SizedBox to add vertical space between widgets?
You want to add 30 pixels of vertical space between two Text widgets. Which code is correct?
Flutter
Column(
  children: [
    Text('Hello'),
    // Add vertical space here
    Text('World')
  ]
)
ASizedBox(height: 30),
BSizedBox(width: 30),
CPadding(padding: EdgeInsets.symmetric(horizontal: 30)),
DContainer(margin: EdgeInsets.all(30)),
Attempts:
2 left
💡 Hint
Vertical space means height, not width.
🔧 Debug
advanced
1:30remaining
Why does this Padding widget not add space around the child?
Given this code, why is there no visible space around the Text widget? Padding(padding: EdgeInsets.zero, child: Text('Hi'))
ABecause EdgeInsets.zero means no padding is applied
BBecause Padding requires a Container child to work
CBecause Text widget ignores Padding always
DBecause Padding only works with SizedBox children
Attempts:
2 left
💡 Hint
Check the padding value used.
🧠 Conceptual
expert
2:30remaining
What is the difference between SizedBox and Padding in Flutter layout?
Choose the best explanation of how SizedBox and Padding differ in affecting widget size and layout.
ASizedBox adds empty space around child; Padding forces child to fixed size
BSizedBox forces its child to a fixed size; Padding adds empty space around its child without changing child's size
CBoth SizedBox and Padding force child to fixed size but Padding adds color
DSizedBox and Padding both only add margin outside the child widget
Attempts:
2 left
💡 Hint
Think about size constraints vs spacing.