π« Stop Using MediaQuery for Responsiveness in Flutter
FlutterPulseThis article was translated specially for the channel FlutterPulseYou'll find lots of interesting things related to Flutter on this channel. Don't hesitate to subscribe!π

MediaQuery is not a responsive design solutionβββit's a screen measurement tool. And yes, there's a difference.
MediaQuery is not a responsive design solution β it's a screen measurement tool. And yes, there's a difference.
It's 2025, and if you're still relying on MediaQuery for responsive design in Flutter, it's time for a mindset shift.
Sure, MediaQuery.of(context).size or the newer MediaQuery.sizeOf(context) feels like the go-to tool when you're trying to adapt your UI to different screen sizes. But here's the truth: fractional sizing is outdated and often ineffective for building truly adaptive experiences β especially when you're building for mobile, web, tablets, and foldables.
β What's Wrong With Fractional Sizing?
Fractional sizing is the practice of defining UI dimensions as a percentage of the screen size, like:
Container(
width: MediaQuery.of(context).size.width * 0.3,
child: Text('Click me!'),
)
At first glance, this looks smart β the widget adapts as the screen grows. But real-world use shows this approach is fragile and leads to unpredictable UX. Why?
- It treats all devices the same.
- It doesn't respect content or intent.
- It assumes screen size = user intent.
A 14" Chromebook and a 14" touchscreen tablet need very different UI strategies, not just rescaled buttons.
β So What's the 2025 Way to Handle Responsiveness in Flutter?
Glad you asked. Flutter has grown, and now we have much better tools in our arsenal:
1. LayoutBuilder is your new best friend
LayoutBuilder helps you respond to the actual available space and build adaptive UIs instead of rigidly scaling things.
LayoutBuilder(
builder: (context, constraints) {
if (constraints.maxWidth > 600) {
return TabletLayout();
} else {
return MobileLayout();
}
},
)
Clean, powerful, and respects device context.
2. Use Flutter's Built-in Breakpoints
With the rise of flutter_responsive_framework, flutter_adaptive, and even Material 3's adaptive design patterns, handling breakpoints and device types is easier than ever.
Want to support tablets and web elegantly?
Use ResponsiveBreakpoints.of(context) (via the responsive_framework package):
if (ResponsiveBreakpoints.of(context).isDesktop) {
return DesktopView();
} else if (ResponsiveBreakpoints.of(context).isTablet) {
return TabletView();
} else {
return MobileView();
}3. Static Fonts Are Fine!
You don't need to scale text with screen width.
Text(
'Hello World',
style: TextStyle(fontSize: 16),
)
This renders just fine on both phones and tablets. Instead of resizing fonts, change layout structure β let text stay readable and reorganize the surrounding elements.
π₯ Overflow Isn't the Enemy β Constraints Are
Most overflow issues in Flutter aren't because you didn't use MediaQuery. They happen because you didn't respect parent constraints.
Use Flexible, Expanded, and Wrap where necessary. Here's a bulletproof layout snippet:
Row(
children: [
Expanded(child: Container(color: Colors.blue)),
Expanded(child: Container(color: Colors.red)),
],
)
That's it. No overflows, no hacks. Let Flutter handle what it's already good at.
π€ΉββοΈ Pro Tip: Go Beyond Mobile
Flutter in 2025 is a multi-platform framework. Your UI should adapt across:
- π± Mobile
- π₯ Web
- π» Desktop
- πΊ TV
- π Foldables & Tablets
Don't think "scaling." Think adaptive UX. More space β bigger widgets β it means better layout, more features, multitasking, better navigation, and deeper interactions.
π§ TL;DR
- β Don't use
MediaQueryfor fractional sizing. - β
Do use
LayoutBuilder, breakpoints, and constraint-aware widgets. - π§± Focus on structure, not scale.
- π Build for multi-platform by adapting layout, not size.
π Final Thoughts
Fractional sizing may seem like a shortcut to responsiveness, but it's holding your app back from being truly adaptive. It's time to let go of the MediaQuery crutch and lean into Flutter's powerful layout engine.
If you're building serious apps for today's diverse platforms, your UI needs to do more than fit β it needs to flex.
π What are you still using
MediaQueryfor in 2025? Let me know in the comments β or better yet, challenge yourself to refactor one screen without it.