
Flutter Build Responsive Layout
Adapt Flutter UIs across phone, tablet, and desktop window sizes without relying on device-type hacks.
Overview
flutter-build-responsive-layout is an agent skill for the Build phase that teaches Flutter adaptive layouts using LayoutBuilder, MediaQuery, and Flexible/Expanded against real window constraints.
Install
npx skills add https://github.com/flutter/skills --skill flutter-build-responsive-layoutWhat is this skill?
- Measure space with MediaQuery.sizeOf and LayoutBuilder constraints.maxWidth—not hardware form factors
- Avoid top-level orientation switches; layout on available app window space instead
- Use Expanded/Flexible and adaptive patterns for large-screen optimization workflows
- Structured workflows for constructing adaptive layouts and optimizing for large screens
- Examples and sizing/constraint guidelines aligned with Flutter layout rules
Adoption & trust: 15.2k installs on skills.sh; 2.4k GitHub stars; 3/3 security scanners passed (skills.sh audits).
What problem does it solve?
Your Flutter UI looks fine on one phone size but breaks on tablets, wide windows, or split-screen because layout decisions use orientation or device type instead of available space.
Who is it for?
Solo builders implementing or refactoring Flutter screens that must work on multiple screen widths from one codebase.
Skip if: Teams that only target a single fixed-size embedded display with no resize behavior, or native-only (non-Flutter) layout systems.
When should I use this skill?
Use LayoutBuilder, MediaQuery, or Expanded/Flexible when the UI must look good on mobile and tablet/desktop form factors.
What do I get? / Deliverables
You get constraint-driven breakpoint choices, documented layout workflows, and widget trees that scale across form factors without hardware-specific branching.
- Constraint-driven responsive widget tree
- Layout patterns avoiding device-type checks
- Large-screen optimization pass on key screens
Recommended Skills
Journey fit
How it compares
Procedural Flutter layout guidance—not a visual design system generator or Figma-to-code plugin.
Common Questions / FAQ
Who is flutter-build-responsive-layout for?
Indie and solo developers shipping Flutter apps who need adaptive layouts for mobile and larger screens without maintaining separate phone vs tablet apps.
When should I use flutter-build-responsive-layout?
Use it in Build (frontend) when adding new screens, fixing overflow on tablets, or optimizing for desktop/window resizing; also when an agent should choose LayoutBuilder breakpoints instead of MediaQuery.orientation at the root.
Is flutter-build-responsive-layout safe to install?
It is documentation-style procedural guidance with no built-in shell or network execution; review the Security Audits panel on this page before installing any skill from the catalog.
SKILL.md
READMESKILL.md - Flutter Build Responsive Layout
# Implementing Adaptive Layouts ## Contents - [Space Measurement Guidelines](#space-measurement-guidelines) - [Widget Sizing and Constraints](#widget-sizing-and-constraints) - [Device and Orientation Behaviors](#device-and-orientation-behaviors) - [Workflow: Constructing an Adaptive Layout](#workflow-constructing-an-adaptive-layout) - [Workflow: Optimizing for Large Screens](#workflow-optimizing-for-large-screens) - [Examples](#examples) ## Space Measurement Guidelines Determine the available space accurately to ensure layouts adapt to the app window, not just the physical device. * **Use `MediaQuery.sizeOf(context)`** to get the size of the entire app window. * **Use `LayoutBuilder`** to make layout decisions based on the parent widget's allocated space. Evaluate `constraints.maxWidth` to determine the appropriate widget tree to return. * **Do not use `MediaQuery.orientationOf` or `OrientationBuilder`** near the top of the widget tree to switch layouts. Device orientation does not accurately reflect the available app window space. * **Do not check for hardware types** (e.g., "phone" vs. "tablet"). Flutter apps run in resizable windows, multi-window modes, and picture-in-picture. Base all layout decisions strictly on available window space. ## Widget Sizing and Constraints Understand and apply Flutter's core layout rule: **Constraints go down. Sizes go up. Parent sets position.** * **Distribute Space:** Use `Expanded` and `Flexible` within `Row`, `Column`, or `Flex` widgets. * Use `Expanded` to force a child to fill all remaining available space (equivalent to `Flexible` with `fit: FlexFit.tight` and a `flex` factor of 1.0). * Use `Flexible` to allow a child to size itself up to a specific limit while still expanding/contracting. Use the `flex` factor to define the ratio of space consumption among siblings. * **Constrain Width:** Prevent widgets from consuming all horizontal space on large screens. Wrap widgets like `GridView` or `ListView` in a `ConstrainedBox` or `Container` and define a `maxWidth` in the `BoxConstraints`. * **Lazy Rendering:** Always use `ListView.builder` or `GridView.builder` when rendering lists with an unknown or large number of items. ## Device and Orientation Behaviors Ensure the app behaves correctly across all device form factors and input methods. * **Do not lock screen orientation.** Locking orientation causes severe layout issues on foldable devices, often resulting in letterboxing (the app centered with black borders). Android large format tiers require both portrait and landscape support. * **Fallback for Locked Orientation:** If business requirements strictly mandate a locked orientation, use the `Display API` to retrieve physical screen dimensions instead of `MediaQuery`. `MediaQuery` fails to receive the larger window size in compatibility modes. * **Support Multiple Inputs:** Implement support for basic mice, trackpads, and keyboard shortcuts. Ensure touch targets are appropriately sized and keyboard navigation is accessible. ## Workflow: Constructing an Adaptive Layout Follow this workflow to implement a layout that adapts to the available `BoxConstraints`. **Task Progress:** - [ ] Identify the target widget that requires adaptive behavior. - [ ] Wrap the widget tree in a `LayoutBuilder`. - [ ] Extract the `constraints.maxWidth` from the builder callback. - [ ] Define an adaptive breakpoint (e.g., `largeScreenMinWidth = 600`). - [ ] **If `maxWidth > largeScreenMinWidth`:** Return a large-screen layout (e.g., a `Row` placing a navigation sidebar and content area side-by-side). - [ ] **If `maxWidth <