0
0
Fluttermobile~20 mins

Column and Row in Flutter - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Master of Column and Row
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 tree:

Column(
  children: [
    Text('A'),
    Row(
      children: [
        Text('B'),
        Text('C'),
      ],
    ),
    Text('D'),
  ],
)

How will the texts be arranged on the screen?

Flutter
Column(
  children: [
    Text('A'),
    Row(
      children: [
        Text('B'),
        Text('C'),
      ],
    ),
    Text('D'),
  ],
)
ATexts A and D arranged vertically, with B and C arranged horizontally between them.
BTexts A, B, C, D arranged vertically in a single column.
CTexts A, B, C, D arranged horizontally in a single row.
DTexts A and D arranged horizontally, with B and C arranged vertically between them.
Attempts:
2 left
💡 Hint

Remember that Column arranges children vertically and Row arranges children horizontally.

📝 Syntax
intermediate
1:30remaining
Which option will cause a syntax error in Flutter layout code?

Identify the Flutter code snippet that will cause a syntax error when used inside a widget tree.

AColumn(children: [Text('M'), Text('N')])
BRow(children: [Text('X'), Text('Y')])
CColumn(children: Text('Z'))
DRow(children: [Text('P')])
Attempts:
2 left
💡 Hint

Check the type expected for the children property.

lifecycle
advanced
2:30remaining
What happens if you nest multiple Columns inside a Row with unbounded width?

Consider a Row widget containing several Column widgets, each with many children. What is the likely runtime behavior?

Flutter
Row(
  children: [
    Column(children: List.generate(50, (i) => Text('Item $i'))),
    Column(children: List.generate(50, (i) => Text('Item $i'))),
  ],
)
AThe app will throw a layout overflow error because Row has unbounded width and Columns try to expand infinitely.
BThe app will crash with a null pointer exception.
CThe app will automatically wrap Columns to the next line to avoid overflow.
DThe app will render all items without issues, scrolling horizontally if needed.
Attempts:
2 left
💡 Hint

Think about how Row and Column handle constraints and available space.

navigation
advanced
2:00remaining
How to make a Row with equally spaced children that respond to taps?

You want a Row with three buttons spaced evenly across the screen width. Which code snippet achieves this with proper tap handling?

A
Row(children: [
  ElevatedButton(onPressed: () {}, child: Text('One')),
  ElevatedButton(onPressed: () {}, child: Text('Two')),
  ElevatedButton(onPressed: () {}, child: Text('Three')),
])
B
Row(mainAxisAlignment: MainAxisAlignment.spaceEvenly, children: [
  ElevatedButton(onPressed: () {}, child: Text('One')),
  ElevatedButton(onPressed: () {}, child: Text('Two')),
  ElevatedButton(onPressed: () {}, child: Text('Three')),
])
C
Row(mainAxisAlignment: MainAxisAlignment.center, children: [
  ElevatedButton(onPressed: () {}, child: Text('One')),
  ElevatedButton(onPressed: () {}, child: Text('Two')),
  ElevatedButton(onPressed: () {}, child: Text('Three')),
])
D
Row(mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [
  ElevatedButton(onPressed: null, child: Text('One')),
  ElevatedButton(onPressed: null, child: Text('Two')),
  ElevatedButton(onPressed: null, child: Text('Three')),
])
Attempts:
2 left
💡 Hint

Check the mainAxisAlignment property and whether buttons are enabled.

🔧 Debug
expert
3:00remaining
Why does this Flutter layout cause a vertical overflow error?

Analyze the code below and identify the cause of the vertical overflow error when rendered on a small screen.

Column(
  children: [
    Expanded(child: ListView(children: [Text('Item 1'), Text('Item 2')])),
    Container(height: 100, color: Colors.blue),
  ],
)
Flutter
Column(
  children: [
    Expanded(child: ListView(children: [Text('Item 1'), Text('Item 2')])),
    Container(height: 100, color: Colors.blue),
  ],
)
AThe ListView inside Expanded tries to take infinite height, conflicting with the fixed height Container.
BThe Column widget does not support Expanded children, causing overflow.
CThe ListView should be wrapped in a SingleChildScrollView to avoid overflow.
DThe Container's fixed height causes the Column to exceed screen height because Expanded takes all remaining space, leaving no room for Container.
Attempts:
2 left
💡 Hint

Consider how Expanded and fixed height widgets share space inside a Column.