Learn/Layout & UI Thinking/Responsive Design

Responsive Design

Build UIs that adapt to any screen size

5 min~5 min read+35 FX

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

Table of Contents

  1. 1. MediaQuery
  2. 2. LayoutBuilder for Adaptive UI
  3. 3. Breakpoint Pattern
  4. 4. Responsive Design As Product Strategy
  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

Responsive Design in Flutter

Responsive design means building interfaces that look great on any screen size, from small phones to large desktop monitors. Flutter provides several tools to help you adapt your layouts.

MediaQuery

MediaQuery gives you access to device and screen information such as width, height, safe area padding, and orientation.

dart
1@override
2Widget build(BuildContext context) {
3 final size = MediaQuery.of(context).size;
4 final width = size.width;
5 final height = size.height;
6 final padding = MediaQuery.of(context).padding; // Safe area
7 final orientation = MediaQuery.of(context).orientation;
8
9 return Container(
10 width: width * 0.9, // 90% of screen width
11 padding: EdgeInsets.only(top: padding.top), // Avoid notch
12 );
13}

LayoutBuilder for Adaptive UI

LayoutBuilder provides the actual constraints given to your widget, which you can use to decide which layout to render based on available space.

dart
1LayoutBuilder(
2 builder: (context, constraints) {
3 if (constraints.maxWidth > 900) {
4 // Desktop layout - 3 columns
5 return DesktopLayout();
6 } else if (constraints.maxWidth > 600) {
7 // Tablet layout - 2 columns
8 return TabletLayout();
9 } else {
10 // Mobile layout - 1 column
11 return MobileLayout();
12 }
13 },
14)

Breakpoint Pattern

A breakpoint pattern is a reusable approach where you define screen width thresholds and switch between different layouts based on those thresholds.

dart
1// Define breakpoints
2class Breakpoints {
3 static const mobile = 600;
4 static const tablet = 900;
5 static const desktop = 1200;
6}
7
8// Responsive helper
9class Responsive extends StatelessWidget {
10 final Widget mobile;
11 final Widget? tablet;
12 final Widget? desktop;
13
14 const Responsive({
15 required this.mobile,
16 this.tablet,
17 this.desktop,
18 });
19
20 @override
21 Widget build(BuildContext context) {
22 return LayoutBuilder(
23 builder: (context, constraints) {
24 if (constraints.maxWidth >= Breakpoints.desktop) {
25 return desktop ?? tablet ?? mobile;
26 } else if (constraints.maxWidth >= Breakpoints.tablet) {
27 return tablet ?? mobile;
28 }
29 return mobile;
30 },
31 );
32 }
33}
34
35// Usage
36Responsive(
37 mobile: MobileProductList(),
38 tablet: TabletProductGrid(),
39 desktop: DesktopProductTable(),
40)

Mobile First

💡 Mobile First

Always build the mobile layout first, then adapt for larger screens. Mobile is the most constrained environment, so starting there ensures your core experience works well.

Responsive Design As Product Strategy

Responsive UI is not only technical adaptation. It is product clarity across contexts.

  • Mobile: prioritize focus and quick actions
  • Tablet: increase density with balanced spacing
  • Desktop: expose richer controls and multi-panel workflows

Different screens should feel native to available space while keeping behavior consistent.

Responsive Readiness Checklist

  • Breakpoints are explicit and reusable.
  • Touch targets remain usable on all layouts.
  • Text and cards do not become cramped or oversized.
  • Primary user flow is equally clear on phone and tablet.

This Lesson In Simple Words

Build UIs that adapt to any screen size. This lesson adds one more building block for creating stable and user-friendly Flutter apps.

Your level focus

Build confidence with basics first; speed comes later.

One practical habit

After reading, rewrite the concept in your own words and apply it in a tiny runnable sample.

Deep Understanding Guide

Why this lesson matters

Each lesson becomes useful when you connect concept, implementation, and real-user outcome together.

Study flow for better retention

  1. Read one section, run one tiny example, then explain the idea in your own words.
  2. Use a simple cycle: understand, implement, test, and explain.
  3. If you can teach it in 45 seconds without notes, you understood it.

Common Mistakes To Avoid

  • Moving forward without checking whether the current concept is truly clear.
  • Copying code exactly without experimenting with small changes.
  • Skipping edge cases and only testing happy-path behavior.
  • Assuming one pattern works for every scenario without trade-off analysis.

Practice Sprint (15-25 Minutes)

  • Before running sample code, predict output and behavior in one sentence.
  • Build one tiny example from memory after finishing this lesson.
  • Write one paragraph about where this concept fits in a real app.
  • Create one failure scenario and verify your app handles it safely.
  • Complete the required exercises without using hints on the first attempt.
  • Answer this question out loud before checking quiz options: "How do you get screen width in Flutter?".

Quick Glossary

  • widget: A reusable UI building block in Flutter.
  • context: A handle to widget location and inherited data in the tree.
  • 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 "Responsive Design" 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: Moving forward without checking whether the current concept is truly clear.
  • 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

How do you get screen width in Flutter?

MediaQuery provides screen and device information.

What does MediaQuery.of(context).padding.top give you?

padding.top is the system UI padding (status bar, notch).

What widget provides available constraints to decide layout?

LayoutBuilder provides the constraints given to your widget, useful for responsive breakpoints.

What is the recommended approach for responsive design?

Build mobile layout first, then adapt for larger screens. Mobile is the most constrained.

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