Skip to content
Back to skills

Responsive Layout

ASecurity

Builds responsive and adaptive Flutter user interfaces across mobile, tablet, desktop, and web form factors using LayoutBuilder, MediaQuery, and adaptive breakpoints.

  • 6 stars
  • 0 votes
  • 0 copies
  • 6 views
  • Added September 7, 2026
ai-agentsperformance

Security analysis

A100/100

Scanned September 7, 2026

npx -y skills add smicolon/ai-kit --skill responsive-layout --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Responsive Layout?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Responsive Layout
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/smicolon-responsive-layout/badge)](https://www.skillsdirectory.com/skills/smicolon-responsive-layout)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: responsive-layout
description: Builds responsive and adaptive Flutter user interfaces across mobile, tablet, desktop, and web form factors using LayoutBuilder, MediaQuery, and adaptive breakpoints.
version: 1.0.0
---

# Responsive Layout in Flutter

Techniques for building cross-platform Flutter layouts that adapt to phones, tablets, foldables, and desktops.

## Breakpoint System

```dart
class ResponsiveBreakpoints {
  static const double mobile = 600;
  static const double tablet = 900;
  static const double desktop = 1200;

  static bool isMobile(BuildContext context) =>
      MediaQuery.sizeOf(context).width < mobile;

  static bool isTablet(BuildContext context) =>
      MediaQuery.sizeOf(context).width >= mobile &&
      MediaQuery.sizeOf(context).width < desktop;

  static bool isDesktop(BuildContext context) =>
      MediaQuery.sizeOf(context).width >= desktop;
}
```

## Pattern 1: `LayoutBuilder` for Component Adaptability

Use `LayoutBuilder` when a component should adapt based on its parent container's width, rather than the entire screen:

```dart
class AdaptiveCardList extends StatelessWidget {
  const AdaptiveCardList({super.key});

  @override
  Widget build(BuildContext context) {
    return LayoutBuilder(
      builder: (context, constraints) {
        if (constraints.maxWidth > 800) {
          // Grid layout on wide containers
          return GridView.builder(
            gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount(
              crossAxisCount: 3,
              childAspectRatio: 1.5,
              crossAxisSpacing: 16,
              mainAxisSpacing: 16,
            ),
            itemCount: 9,
            itemBuilder: (context, index) => CardTile(index),
          );
        } else {
          // Vertical list on narrow containers
          return ListView.builder(
            itemCount: 9,
            itemBuilder: (context, index) => CardTile(index),
          );
        }
      },
    );
  }
}
```

## Pattern 2: Master-Detail Layout for Tablets/Desktop

```dart
Widget build(BuildContext context) {
  final isWide = ResponsiveBreakpoints.isTablet(context) || ResponsiveBreakpoints.isDesktop(context);

  if (isWide) {
    return Row(
      children: [
        const SizedBox(width: 320, child: ItemsListPane()),
        const VerticalDivider(width: 1),
        const Expanded(child: ItemDetailPane()),
      ],
    );
  }

  return const ItemsListPane(); // Mobile pushes to detail route
}
```

## Performance Note: `MediaQuery.sizeOf(context)`
In Flutter 3.10+, use `MediaQuery.sizeOf(context)` instead of `MediaQuery.of(context).size`. `sizeOf` only triggers re-renders when the size changes, preventing rebuilds on orientation/insets changes.

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in ai-agents →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.