Flutter runs on phones, tablets, foldables, in browser windows and on desktops, and it has no built-in idea of a breakpoint. It tells you how big the window is and how much room a widget has, and leaves the rest to you.

What usually happens next is this line:

final isTablet = MediaQuery.of(context).size.width > 600;

It works. Then a second screen needs the same thing, with 640, because that looked better there. A third one asks for the orientation instead. After a while the layout decisions of the app are spread over many files, and nobody can say at which width it changes its shape.

In 2020 I wrote a small package for this, Hydra. Version 2.0 came out in November 2026. This post is about what I think works for responsive layouts in Flutter. The package is that opinion written down as code.

The example app of Hydra, resized from phone to desktop width and back: navigation, header and grid adapt

The recording shows the example app of the package, one widget tree, resized from 390 to 1320 wide and back.

Ask how wide the window is

The first decision is what to ask. The tempting questions are “is this a tablet?” and “is this landscape?”, and both are the wrong ones.

An iPad in split view can be narrower than a phone held sideways. A desktop window can have any width at all, and a foldable changes its width while the app is running. “Tablet” says nothing reliable about how much room there is, and neither does “landscape”. Flutter’s own best practices say the same: don’t check for the type of device, and don’t build layouts on the orientation.

What is left is one number, the width of the window:

final width = MediaQuery.sizeOf(context).width;

sizeOf matters here. MediaQuery.of(context) rebuilds the widget for every change in the media query, and that includes the keyboard sliding in and the user changing the text size. sizeOf only reacts to the size.

Name the breakpoints once

One number is still too many values to design for. So the width is cut into a few named ranges, and the names are what the rest of the app talks about.

Hydra has four: mini, small, medium and large. By default they change at 600, 900 and 1200.

mini small medium large 600 900 1200 phone, 390 tablet, upright, 768 desktop window, 1320
The default ranges. A window is sorted by its width alone, whatever device it is on.

There are presets for the numbers of Material Design, Bootstrap and Tailwind, and one that follows the widths of Apple’s devices. The choice is made in one place, above the app:

HydraScope(
  behaviour: const HydraBehaviour.material(),
  child: MaterialApp(...),
)

Which numbers you take matters less than that they exist once. The first version of Hydra had defaults of 90, 400 and 800. Since version 1.1 they are the ones above. Because they lived in one place, changing them was one line.

Change as little as possible

When the breakpoint changes, a layout can respond on three levels. I take the smallest one that does the job.

The smallest is a value. The screen stays the same, and a padding, a font size or a number of columns changes:

Padding(
  padding: EdgeInsets.all(context.hydra<double>(mini: 16, large: 32)),
  child: HydraGrid.builder(
    mini: 2,
    medium: 3,
    large: 4,
    itemCount: products.length,
    itemBuilder: (context, index) => ProductCard(products[index]),
  ),
)

The next one is presence. Something is there on some widths and not on others. The usual case is navigation, with a rail on the side when there is room and a bar at the bottom when there isn’t:

HydraVisibility(
  visibleFrom: Breakpoint.medium,
  child: const SideNavigation(),
)

HydraVisibility(
  visibleUntil: Breakpoint.small,
  child: const BottomBar(),
)

The biggest is a different widget:

HydraWidget(
  mini: const PhoneLayout(),
  large: const DesktopLayout(),
)

This one is the most expensive, and not because of the frame time. There are now two trees to maintain, and every feature has to be built into both. The state inside PhoneLayout is also gone the moment the window gets wide enough for DesktopLayout. Sometimes two layouts really are that different. Most of the time a value and a visibility are enough, and the screen stays one screen.

Not every breakpoint needs a value

The example above has no small and no medium, and that is on purpose.

Hydra picks the nearest breakpoint that has a value. With mini and large given, small gets the phone layout and medium gets the desktop one. When two are equally near, the larger one wins, and that can be turned around.

mini small medium large you write Hydra shows PhoneLayout PhoneLayout nothing PhoneLayout nothing DesktopLayout DesktopLayout DesktopLayout
Two variants are enough for four ranges. Each empty range takes the nearest one that has a value.

It sounds like a detail, but it changes how the code reads. I don’t have to fill in a table with four columns for every padding. I write down where something changes, and everything else follows.

What happens inside

There is not much machinery behind this, and it runs in three steps.

The HydraScope reads the size of the window from the MediaQuery at its place in the tree. It compares the width with the three numbers and gets one of the four breakpoints. Then it offers that breakpoint to everything below it through an InheritedWidget, the same mechanism Flutter uses to hand a theme down the tree.

MediaQuery the size of the window size, on every change HydraScope width < 600? < 900? < 1200? breakpoint, only when it changes context.hydra picks a value HydraVisibility shows or hides HydraWidget picks a widget
The size is read in one place. Everything below only hears about the breakpoint.

A Hydra widget further down asks for the breakpoint and picks from what it was given: a value, a child to show or hide, or one of several widgets. If nothing was given for that breakpoint, it takes the nearest one, as described above.

Without a scope it still works. Each widget then reads the size itself and uses the default numbers.

Rebuilds while the window is dragged

On a phone the window changes its size when the device is rotated or folded, which is rare. On the desktop and in the browser someone grabs the edge of the window and drags, and the size changes with every frame.

Until version 2.0.1 every Hydra widget asked for the window size itself. That made each of them depend on the size, so each of them was rebuilt for every one of those frames. Dragging a window from 390 to 1320 wide crosses three breakpoints. The widgets were rebuilt hundreds of times to find out, three times, that something had changed.

Now the HydraScope asks once. It turns the size into a breakpoint and hands that down, and the widgets below it depend on the breakpoint. They are rebuilt three times on that drag.

size changes breakpoint changes 600 900 1200 mini small medium large 390 1320
One drag from 390 to 1320 wide. The marks in the upper row illustrate the stream of size changes, they are not a count.

The general point does not need the package. A widget should depend on the thing it actually uses. A layout that only cares which of four ranges it is in should not be told about every pixel.

What a breakpoint can’t tell you

Two limits belong here, because the breakpoint is easy to overuse.

The first is that most of a layout should not need one. A column that stretches, a row of chips that wraps onto a second line and a text block that stops growing at a readable width all adapt continuously, with Expanded, Wrap and ConstrainedBox. Breakpoints are for the few places where the structure changes: where the navigation moves or a second pane appears.

The second is that Hydra answers how wide the window is. It does not answer how wide a widget’s own box is. A card does not know from the breakpoint whether it sits in the main area or in a narrow sidebar. A component that has to adapt to its own space needs LayoutBuilder, which hands it the constraints of its parent. That is a different question, and it has a different tool.

The moment of the change

On a phone hardly anyone sees a breakpoint change. On the desktop the user drags right through it, and a navigation rail that pops into existence looks like a glitch.

So in version 2 the change can be animated:

HydraVisibility(
  visibleFrom: Breakpoint.medium,
  transition: const HydraTransition.size(alignment: Alignment.centerLeft),
  child: const SideNavigation(),
)

The rail grows in from the left, and the content next to it makes room gradually instead of jumping. There is a fade and a scale as well. The recording at the top shows them in the example app.

Small on purpose

The first commit is from March 2020 and version 0.1.0 from that August. After that nothing happened until February 2026.

Hydra today is about 1,100 lines of code. It depends on nothing but Flutter, and 120 tests cover every line of it. It does not try to be a layout framework. It gives the four ranges a name, keeps the numbers in one place and tells a widget when the range changes.

flutter pub add hydra

The code is on GitHub.