Mobile Development10 min read
Flutter Responsive Design for Every Screen
Learn how to build Flutter layouts that adapt to phones, tablets and desktops: breakpoints, LayoutBuilder, MediaQuery and flexible widgets that scale.
- #flutter
- #responsive-design
- #layout
- #breakpoints
- #screen-size
- #adaptive-ui

Most Flutter apps are designed on one phone and tested on one phone, then they meet a tablet, a foldable, or a desktop window and fall apart. Buttons overflow, grids stretch into a single long column, and a layout that looked polished at 390 pixels wide looks lost at 1,440. Responsive design is the discipline of making one codebase look right on every screen size, and Flutter is unusually good at it because its layout system is built around constraints, not fixed pixel positions. This guide shows how to build responsive Flutter layouts for phones, tablets, and desktops: breakpoints, LayoutBuilder versus MediaQuery, grids and navigation that reflow with width, safe text scaling, and testing at every size.
What is responsive design in Flutter?
Responsive design in Flutter means a layout that changes its structure based on the space available to it, instead of assuming one fixed screen size. A responsive app shows a single-column list on a phone, a two-column grid on a tablet, and a sidebar plus content area on a desktop, all from the same widget tree and codebase. Decisions come from constraints and available width, not from detecting a device model, which keeps the app working on foldables, split-screen windows, and desktop resizes that no device check could predict. Flutter makes this natural because widgets receive constraints from their parent and choose their own size inside them. A Row, a Column, a Wrap, and a GridView all behave differently depending on how much room they get, so responsive design is mostly deciding which arrangement to use at each width and letting the framework do the measuring. The tools for that decision are breakpoints, LayoutBuilder, and MediaQuery.
How do you choose breakpoints for a Flutter app?
Breakpoints are the widths at which your layout changes shape, and the simplest reliable set comes from Material Design window size classes: compact below 600 dp, medium from 600 to 840 dp, and expanded above 840 dp. Most apps need only two or three breakpoints, because each one is another layout to design, test, and maintain. Pick them from your content, not from a device list: a breakpoint belongs where your current layout starts to look wrong, such as when a card row grows too wide to read. A practical default is a mobile layout below 600 dp, a tablet layout from 600 to 1,100 dp, and a desktop layout above 1,100 dp. That covers phones in portrait and landscape, most tablets, and desktop windows, while keeping the number of layouts small enough to maintain. The exact numbers matter less than consistency: define them once in a single place, such as a small helper function, and read them everywhere instead of scattering magic numbers through your widgets.
enum ScreenSize { compact, medium, expanded }
ScreenSize screenSizeForWidth(double width) {
if (width < 600) return ScreenSize.compact;
if (width < 1100) return ScreenSize.medium;
return ScreenSize.expanded;
}
How does LayoutBuilder make a layout adapt?
LayoutBuilder is the widget to reach for when a layout decision depends on the space a widget actually gets, rather than the size of the whole screen. It rebuilds its child with a BoxConstraints object describing the maximum width and height available, so the same widget can show one column inside a narrow card and two columns inside a wide one. That distinction matters: a sidebar panel and the main content area share one screen but have very different widths, and only LayoutBuilder can see each one's real space. Use LayoutBuilder around the part of the UI that changes shape, not around the whole page: read constraints.maxWidth once and return the matching widget. Because it rebuilds whenever constraints change, the layout also adapts when a desktop window is resized or a phone rotates. The example below switches a grid between one, two, and three columns.
class AdaptiveGrid extends StatelessWidget {
const AdaptiveGrid({super.key, required this.items});
final List<String> items;
@override
Widget build(BuildContext context) {
return LayoutBuilder(
builder: (context, constraints) {
final width = constraints.maxWidth;
final columns = width < 600 ? 1 : width < 1100 ? 2 : 3;
return GridView.builder(
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
crossAxisCount: columns,
crossAxisSpacing: 16,
mainAxisSpacing: 16,
childAspectRatio: 1.4,
),
itemCount: items.length,
itemBuilder: (context, index) => Card(
child: Center(child: Text(items[index])),
),
);
},
);
}
}
When should you use MediaQuery instead of LayoutBuilder?
MediaQuery is the right tool when a decision depends on the whole screen or the device, rather than on the space one widget gets. It exposes the screen size, the device pixel ratio, the orientation, and the padding taken by notches, status bars, and system navigation, so use it for decisions like whether the app is in landscape or how much safe area to reserve. The modern way to read it is MediaQuery.sizeOf(context), which only rebuilds the widget when the size itself changes. Do not use MediaQuery for a widget buried deep inside a layout, because it cannot see how much space that widget actually has: a panel 300 pixels wide inside a 1,400-pixel window still reports the full screen width and chooses the desktop layout. The rule is simple: MediaQuery answers questions about the screen, LayoutBuilder answers questions about the space.
@override
Widget build(BuildContext context) {
final size = MediaQuery.sizeOf(context);
final isLandscape = size.width > size.height;
final padding = MediaQuery.paddingOf(context);
return Scaffold(
body: Padding(
padding: EdgeInsets.only(top: padding.top),
child: isLandscape ? const WideHome() : const NarrowHome(),
),
);
}
How do you build navigation that adapts to wide screens?
Navigation is the most visible place where a responsive layout changes, because a bottom navigation bar that works on a phone wastes a wide desktop screen. The standard pattern is a bottom navigation bar on compact screens and a NavigationRail on medium and expanded screens, with the same destinations and the same selected index on both. The rail sits on the left, the content fills the rest, and switching between the two is a single width check in the scaffold. Keep the destinations identical in both layouts so users who resize a window never lose their place. The selected index lives in the parent widget, both navigation widgets read it, and both report taps to the same callback. That one swap is often the biggest improvement a desktop user notices, because it turns a stretched phone app into one that feels made for the screen it is on. If your app uses named routes, the same width check pairs well with the routing setup in the go_router guide, which keeps the destination and the URL in sync on every screen size.
class AdaptiveScaffold extends StatefulWidget {
const AdaptiveScaffold({super.key});
@override
State<AdaptiveScaffold> createState() => _AdaptiveScaffoldState();
}
class _AdaptiveScaffoldState extends State<AdaptiveScaffold> {
int _index = 0;
static const _destinations = ['Home', 'Search', 'Settings'];
@override
Widget build(BuildContext context) {
return LayoutBuilder(
builder: (context, constraints) {
final wide = constraints.maxWidth >= 600;
final body = Center(child: Text(_destinations[_index]));
if (wide) {
return Scaffold(
body: Row(
children: [
NavigationRail(
selectedIndex: _index,
onDestinationSelected: (i) => setState(() => _index = i),
destinations: const [
NavigationRailDestination(
icon: Icon(Icons.home),
label: Text('Home'),
),
NavigationRailDestination(
icon: Icon(Icons.search),
label: Text('Search'),
),
NavigationRailDestination(
icon: Icon(Icons.settings),
label: Text('Settings'),
),
],
),
const VerticalDivider(width: 1),
Expanded(child: body),
],
),
);
}
return Scaffold(
body: body,
bottomNavigationBar: BottomNavigationBar(
currentIndex: _index,
onTap: (i) => setState(() => _index = i),
items: const [
BottomNavigationBarItem(icon: Icon(Icons.home), label: 'Home'),
BottomNavigationBarItem(icon: Icon(Icons.search), label: 'Search'),
BottomNavigationBarItem(icon: Icon(Icons.settings), label: 'Settings'),
],
),
);
},
);
}
}
How do you scale text and spacing without breaking the layout?
Text and spacing should grow with the screen, but never without a limit. The common mistake is a fixed font size and padding that look right on a phone and tiny on a desktop, or the opposite: scaling everything by screen width until a headline fills half the screen. The safe approach is to pick sizes from the breakpoint, not from the raw width, and to clamp every scaled value between a minimum and a maximum. A headline that is 24 on compact screens, 32 on medium, and 40 on expanded screens is predictable and easy to check. For spacing, prefer flexible widgets over fixed SizedBox heights: Expanded and Flexible divide the available space, Spacer pushes content apart without hard-coded gaps, and FittedBox shrinks a single line of text to fit instead of overflowing. Wrap long rows in a Wrap widget so items flow onto a second line on narrow screens. And always test with the largest accessibility text size enabled, because a user who scales text to 200 percent will find every fixed-height container you forgot.
double headlineSizeForWidth(double width) {
if (width < 600) return 24;
if (width < 1100) return 32;
return 40;
}
What mistakes break responsive Flutter layouts?
Most responsive layouts break in the same few ways, and all of them come from assuming a fixed size somewhere in the tree. Check a new screen against this list before shipping it, because each mistake is cheaper to fix in development than in a one-star review.
| Mistake | What you see | Fix |
|---|---|---|
| Hard-coded widths such as SizedBox with a fixed width | Overflow errors on small phones, empty space on tablets | Use Expanded, Flexible, or a fraction of the available width |
| MediaQuery.sizeOf deep inside a nested widget | A narrow panel chooses the desktop layout | Use LayoutBuilder, which sees the space the widget actually gets |
| Designing for one device only | A layout that works on your phone and breaks on a foldable | Test at 360, 600, 840, and 1280 dp widths |
| Fixed-height containers around text | Text clipped when the user enables large accessibility text | Let containers size to their content, or use FittedBox |
| Ignoring orientation | A landscape phone shows a stretched portrait layout | Check width against height, or re-run the breakpoint logic |
How do you test responsive layouts in Flutter?
Testing a responsive layout means checking it at several widths, not just on your own phone, and Flutter makes that cheap. Widget tests can set the test window size directly, so one test file can pump the same screen at 390, 768, and 1,280 pixels wide and assert that the right layout appears at each size. Set the size with tester.view.physicalSize and tester.view.devicePixelRatio, then check for the widget that only exists in that layout, such as a NavigationRail on wide screens. Reset the size in tearDown so later tests are not affected. Golden tests add a visual check: render the same screen at two or three widths and compare the screenshots against stored goldens, which catches spacing and overflow problems that widget assertions miss. Run the same checks on a real tablet and a desktop window at least once before release. The combination of sized widget tests, goldens, and one real-device pass keeps a responsive layout honest as the app grows. Keeping these responsive widgets in a clear folder structure helps too, as described in the clean architecture guide.
testWidgets('shows a rail on wide screens', (tester) async {
tester.view.physicalSize = const Size(1280, 800);
tester.view.devicePixelRatio = 1.0;
addTearDown(tester.view.resetPhysicalSize);
addTearDown(tester.view.resetDevicePixelRatio);
await tester.pumpWidget(const MaterialApp(home: AdaptiveScaffold()));
expect(find.byType(NavigationRail), findsOneWidget);
expect(find.byType(BottomNavigationBar), findsNothing);
});
Conclusion
Responsive design in Flutter is not a feature you add at the end. It is a set of small decisions made while building each screen: define your breakpoints once, use LayoutBuilder for space and MediaQuery for the screen, swap navigation at the medium breakpoint, size text by breakpoint with a cap, and test at four widths. Do that consistently and one codebase will look deliberate on a phone, a tablet, a foldable, and a desktop. Start with the screen you already have. Find one hard-coded width, replace it with a breakpoint decision, and run the app at 360 and 1,280 pixels wide. That single change is the habit that makes every screen after it responsive by default. Get in touch and let's talk about your project.
Frequently asked questions
- What is responsive design in Flutter?
- Responsive design in Flutter means a layout that changes its structure based on the space available to it. The same codebase shows a single-column list on a phone, a grid on a tablet, and a sidebar layout on a desktop, with decisions driven by constraints and available width rather than device models.
- Should I use LayoutBuilder or MediaQuery for responsive layouts?
- Use LayoutBuilder when the decision depends on the space a specific widget gets, such as a panel inside a wider page. Use MediaQuery when the decision depends on the whole screen, such as orientation, screen size at the top of the page, or safe area padding.
- What breakpoints should I use in a Flutter app?
- A practical default is a mobile layout below 600 dp, a tablet layout from 600 to 1,100 dp, and a desktop layout above 1,100 dp. Material Design window size classes use compact below 600 dp, medium from 600 to 840 dp, and expanded above 840 dp.
- How do I test a responsive Flutter layout?
- Set the test window size with tester.view.physicalSize and tester.view.devicePixelRatio in a widget test, pump the screen, and assert that the correct layout appears at each width. Golden tests add a visual check at multiple widths, and a real tablet or desktop window confirms how the layout behaves when resized.


