Learn/Core Widgets/Row & Column

Row & Column

Layout widgets horizontally and vertically

5 min~5 min read+30 FX

You can read this lesson publicly. Sign in to unlock exercises, quiz, and FX progress tracking.

Table of Contents

  1. 1. MainAxisAlignment
  2. 2. CrossAxisAlignment
  3. 3. Practical Example
  4. 4. Layout Debugging Workflow
  5. 5. This Lesson In Simple Words
  6. 6. Your level focus
  7. 7. One practical habit
  8. 8. Deep Understanding Guide
  9. 9. Why this lesson matters
  10. 10. Study flow for better retention
  11. 11. Quick Glossary

Having trouble? AI is here to help

Ask context-aware questions about this lesson. Free plan: 5 questions/day. Upgrade to Premium for higher daily limits.

Use the AI button at the bottom of the screen

Row and Column

Row and Column are the two most important layout widgets in Flutter. Nearly every screen you build will use one or both of them.

  • Row arranges its children horizontally from left to right.
  • Column arranges its children vertically from top to bottom.
dart
1// Row - horizontal layout
2Row(
3 children: [
4 Icon(Icons.star),
5 Text('4.5'),
6 Text('(120 reviews)'),
7 ],
8)
9
10// Column - vertical layout
11Column(
12 children: [
13 Text('Title'),
14 Text('Subtitle'),
15 ElevatedButton(onPressed: () {}, child: Text('Action')),
16 ],
17)

MainAxisAlignment

MainAxisAlignment controls how children are spaced along the main direction of the layout. For a Row, that means horizontally. For a Column, that means vertically.

dart
1Row(
2 mainAxisAlignment: MainAxisAlignment.spaceBetween,
3 children: [
4 Text('Left'),
5 Text('Right'),
6 ],
7)
8
9// Options:
10// start - [■ ■ ■ ]
11// end - [ ■ ■ ■]
12// center - [ ■ ■ ■ ]
13// spaceBetween - [■ ■ ■]
14// spaceAround - [ ■ ■ ■ ]
15// spaceEvenly - [ ■ ■ ■ ]

CrossAxisAlignment

CrossAxisAlignment controls how children are aligned on the axis perpendicular to the main direction. For a Row, the cross axis is vertical. For a Column, the cross axis is horizontal.

dart
1Row(
2 crossAxisAlignment: CrossAxisAlignment.start,
3 children: [
4 Container(height: 50, width: 50, color: Colors.red),
5 Container(height: 100, width: 50, color: Colors.blue),
6 ],
7)
8
9// Options:
10// start - align to top (Row) or left (Column)
11// end - align to bottom (Row) or right (Column)
12// center - center alignment
13// stretch - stretch to fill cross axis

Memory Trick

💡 Memory Trick

Main axis is the direction of flow (horizontal for Row, vertical for Column). Cross axis is perpendicular to the main axis. Understanding this distinction is key to mastering Flutter layouts.

Practical Example

Here is a common pattern you will see in real Flutter apps: a profile header that combines Row and Column together.

dart
1// Profile header
2Row(
3 children: [
4 CircleAvatar(radius: 30, child: Text('JD')),
5 SizedBox(width: 12),
6 Column(
7 crossAxisAlignment: CrossAxisAlignment.start,
8 children: [
9 Text('John Doe', style: TextStyle(fontWeight: FontWeight.bold)),
10 Text('Flutter Developer', style: TextStyle(color: Colors.grey)),
11 ],
12 ),
13 Spacer(), // Pushes everything after it to the end
14 IconButton(icon: Icon(Icons.more_vert), onPressed: () {}),
15 ],
16)

Layout Debugging Workflow

When Row/Column layouts break, debug in this order:

  1. Check parent constraints
  2. Check main and cross axis alignment
  3. Add temporary colored Containers to visualize boundaries
  4. Use Expanded/Flexible where overflow happens
  5. Add SizedBox spacing intentionally

This process solves most layout bugs faster than random property changes.

Overflow Prevention Checklist

  • Long text is wrapped or constrained.
  • Rows with dynamic text use Expanded or Flexible.
  • Spacing scales down gracefully on small screens.
  • Layouts are tested on narrow and wide devices.

This Lesson In Simple Words

Layout widgets horizontally and vertically. Widgets are reusable UI blocks. You combine them like LEGO pieces to build screens.

Your level focus

Build confidence with basics first; speed comes later.

One practical habit

Sketch the widget tree first, then code from top to bottom.

Deep Understanding Guide

Why this lesson matters

Most Flutter productivity comes from understanding layout rules and composing widgets cleanly.

Study flow for better retention

  1. Read one section, run one tiny example, then explain the idea in your own words.
  2. When a UI bug appears, inspect constraints and parent-child relations before changing random values.
  3. If you can teach it in 45 seconds without notes, you understood it.

Common Mistakes To Avoid

  • Nesting too many widgets without extracting reusable pieces.
  • Ignoring constraints and guessing with random SizedBox heights.
  • Using one giant build method for unrelated UI sections.
  • Putting heavy calculations directly in build methods.

Practice Sprint (15-25 Minutes)

  • Before running sample code, predict output and behavior in one sentence.
  • Build one card layout with Row/Column and rebuild it using Stack for comparison.
  • Split a large widget into 3 smaller widgets with clear responsibilities.
  • Use const constructors where possible and observe rebuild behavior.
  • Complete the required exercises without using hints on the first attempt.
  • Answer this question out loud before checking quiz options: "Row lays out children in which direction?".

Quick Glossary

  • widget: A reusable UI building block in Flutter.
  • build: The method that describes UI for the current state.
  • const: A compile-time constant that can reduce rebuild work.

Code Comprehension Drill

  • State the purpose of the code block in one line before reading details.
  • Mark inputs, state changes, and final output.
  • Change one small value and predict what should happen before running.
  • Run again and compare your prediction with actual behavior.

Lesson Completion Checklist

  • I can explain "Row & Column" in simple words without reading notes.
  • I can describe one real app situation where this concept is required.
  • I know at least one mistake to avoid: Nesting too many widgets without extracting reusable pieces.
  • I can modify one code sample and correctly predict the behavior change.
  • I can finish required exercises with understanding, not trial-and-error guesses.

Frequently Asked Questions

Row lays out children in which direction?

Row arranges children horizontally from left to right.

MainAxisAlignment.spaceBetween does what?

spaceBetween distributes children with equal space between them, none at edges.

What widget pushes remaining space?

Spacer takes up all available space, pushing siblings to the edges.

CrossAxisAlignment.start in a Row aligns children to:

For Row, cross axis is vertical, so start means top.

Suggest Improvement

Something seems incorrect, unclear, or missing? Let us know.

About The Author

FlutterCraft editorial lessons are reviewed by experienced Flutter developers and updated to stay aligned with modern Flutter and Dart best practices.

Reference docs: Flutter Documentation, Dart Language Tour, and official package documentation where relevant.

Sign in to continue with exercises and quiz for this lesson.

Sign In to Continue