Advanced Responsive: A Complete Material Design 3-Based Responsive System for Flutter
Source: Dev.to
Building responsive layouts in Flutter
Responsive layouts in Flutter often start simple… and quickly become messy.
You begin with a few MediaQuery checks, then add breakpoint logic, then multiply values by scale factors. Before long, your widgets are tangled in conditional rendering and hard‑coded dimensions.
advanced_responsive is designed to solve that by providing a structured, Material Design 3‑aligned responsive system, not just scaling utilities or breakpoint checks.
The problem
Most Flutter developers encounter these issues:
// Different developers, different values
if (width width;
// ... repeated in every widget
- Spacing, typography, and layout decisions are scattered across the codebase with no central source of truth.
Existing solutions
| Solution | Focus |
|---|---|
flutter_screenutil | Scaling utilities |
responsive_framework | Breakpoint checks |
responsive_builder | Layout switching |
Real‑world responsive design needs all of them working together.
advanced_responsive – three pillars
| Pillar | What it gives you |
|---|---|
| Consistency | One source of truth for breakpoints and spacing |
| Readability | Semantic APIs that make intent clear |
| Maintainability | Easy to modify and scale as your project grows |
The package uses the official MD3 breakpoints:
| Device Type | Width Range | Grid Columns |
|---|---|---|
| Mobile | (see note below) | |
| Tablet | (see note below) | |
| Desktop | (see note below) |
90 % of apps need the same UI that adapts automatically.
10 % need completely different layouts per device.
advanced_responsive supports both.
Adaptive UI (same UI, different spacing/typography)
ResponsiveBuilder(
builder: (context, info) => Container(
padding: EdgeInsets.all(info.spacing(ResponsiveSpacing.md)),
child: Text(
'Welcome',
style: TextStyle(fontSize: info.responsiveFontSize(24)),
),
),
);
Custom UI (different layouts per device)
ResponsiveLayout(
mobile: MobileView(),
tablet: TabletView(),
desktop: DesktopView(),
);
Conditional rendering example
ResponsiveBuilder(
builder: (context, info) {
return Column(
children: [
Text(
info.isDesktop ? 'Desktop Mode' : 'Mobile Mode',
style: TextStyle(fontSize: info.responsiveFontSize(18)),
),
if (info.isDesktop)
ThreeColumnLayout()
else if (info.isTablet)
TwoColumnLayout()
else
SingleColumnLayout(),
],
);
},
);
Completely different layouts per device
ResponsiveLayout(
mobile: MobileHomePage(), // Bottom nav, single column
tablet: TabletHomePage(), // Side drawer, 2 columns
desktop: DesktopHomePage(), // Top nav, 3 columns, sidebar
);
Helpers available directly on BuildContext
| Category | Helpers |
|---|---|
| Device detection | context.isMobilecontext.isTabletcontext.isDesktopcontext.isLandscape |
| Spacing | context.spacing(ResponsiveSpacing.md)context.horizontalPadding()context.safePadding |
| Typography | context.responsiveFontSize(18) |
| Screen helpers | context.isNarrowScreen // 1000 px (fold phones) |
No wrappers. No boilerplate.
Semantic spacing values
| Spacing | Mobile | Tablet | Desktop |
|---|---|---|---|
| xs | 4 | 6 | 8 |
| sm | 8 | 12 | 16 |
| md | 16 | 24 | 32 |
| lg | 24 | 32 | 48 |
| xl | 32 | 48 | 64 |
| xxl | 48 | 64 | 96 |
Before
// Before
Container(
padding: EdgeInsets.all(
MediaQuery.of(context).size.width ProductCard(),
);
}
}
With advanced_responsive
class ProductGrid extends StatelessWidget {
@override
Widget build(BuildContext context) {
return ResponsiveBuilder(
builder: (context, info) {
final columns = info.responsiveValue(
mobile: 2,
tablet: 3,
desktop: 4,
);
return GridView.builder(
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
crossAxisCount: columns,
mainAxisSpacing: info.spacing(ResponsiveSpacing.sm),
crossAxisSpacing: info.spacing(ResponsiveSpacing.sm),
),
itemBuilder: (context, index) => ProductCard(),
);
},
);
}
}
Improvements
- ✅ Cleaner, more readable
- ✅ Semantic spacing values
- ✅ Easy to modify centrally
- ✅ Type‑safe device detection
Service example (caching)
class ResponsiveService {
static final ResponsiveService _instance = ResponsiveService._internal();
DeviceType? _cachedDeviceType;
double? _cachedWidth;
DeviceType getDeviceType(double width) {
if (_cachedWidth == width) return _cachedDeviceType!;
// … calculate and cache
}
}
Benefits
- Minimal overhead
- No unnecessary recalculations
- Efficient memory usage
See it in action
🌐 Try the Live Demo
- Open the link in your browser.
- Press F12 to open DevTools and inspect the responsive helpers in action.
📱 Toggle Device Toolbar
Resize the viewport
| Width | Device |
|---|---|
| 320 px | Small mobile |
| 600 px | Tablet |
| 840 px | Desktop |
| 1200 px | Large desktop |
Observe
- Layout changes (columns, navigation)
- Spacing adaptation
- Typography scaling
- Grid column changes
Packages & Features
| Feature | advanced_responsive | responsive_framework | responsive_builder | flutter_screenutil |
|---|---|---|---|---|
| MD3 breakpoints | ✅ | ❌ Custom | ❌ Custom | ❌ Custom |
| Adaptive spacing | ✅ Built‑in | ❌ Manual | ❌ Manual | ⚠️ Scaling only |
| Responsive typography | ✅ | ❌ | ❌ | ⚠️ Pixel‑based |
| Context extensions | ✅ Rich API | ⚠️ Limited | ⚠️ Basic | ⚠️ Limited |
| Zero config | ✅ | ❌ Requires setup | ✅ | ❌ Requires init |
| Grid system | ✅ Auto | ❌ | ❌ | ❌ |
| SafeArea helpers | ✅ | ❌ | ❌ | ❌ |
| Dependencies | 0 | Multiple | 0 | 0 |
| Package size | Small | Large | Small | Small |
Installation
dependencies:
advanced_responsive: ^1.0.3
import 'package:advanced_responsive/advanced_responsive.dart';
Minimal Example
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
home: ResponsiveBuilder(
builder: (context, info) => Scaffold(
body: Padding(
padding: context.safePadding,
child: Text(
'Hello Responsive World!',
style: TextStyle(
fontSize: context.responsiveFontSize(24),
),
),
),
),
),
);
}
}
Do’s & Don’ts
| ❌ | ✅ |
|---|---|
padding: EdgeInsets.all(16) | padding: EdgeInsets.all(context.spacing(ResponsiveSpacing.md)) |
Only when necessaryResponsiveLayout( mobile: MobileView(), desktop: DesktopView(), ) | Prefer adaptiveResponsiveBuilder( builder: (context, info) => MyView( columns: info.responsiveValue(mobile: 1, tablet: 2, desktop: 3), ), ) |
VerboseResponsiveBuilder( builder: (context, info) { if (info.isMobile) { … } }, ) | Conciseif (context.isMobile) { … } |
Frequently Asked Questions
Q: Do I really need a responsive package?
A: No! That’s a common misconception. 90 % of apps only need the same UI with adaptive spacing, typography, and layout adjustments. The package handles this automatically.
Q: Can I migrate gradually?
A: Absolutely! You can migrate one screen at a time. The context extensions make it easy to replace existing MediaQuery calls incrementally.
Q: Is it cross‑platform?
A: Yes! The package is platform‑agnostic and works seamlessly across Mobile, Web, and Desktop.
Q: What’s the impact on app size?
A: Minimal – the package adds roughly ~50 KB to your app.
Q: Is it production‑ready?
A: Yes! It’s well‑tested, used in production apps, and actively maintained.
Feature Wishlist
- Animated transitions between breakpoints
- Debug overlay
- Platform‑specific values
- Responsive theme system
- Custom breakpoint support
- Performance improvements
- CLI migration tool
- Adaptive widgets library
- Testing utilities
Why Choose advanced_responsive?
- ✅ Reduces boilerplate
- ✅ Enforces design consistency
- ✅ Scales well as your project grows
- ✅ Follows industry standards (Material Design 3)
- ✅ Provides both adaptive and custom layout options
📦 pub.dev 🐙 GitHub 🌐 Live Demo
Found a bug? Have a feature request?
- 🗳️ Vote on features: GitHub Discussions
- 🤝 Contribute: Contributing Guide
- 🐛 Open an issue
- 🔧 Submit a PR: Fork the repo and contribute!
- ⭐ Star on GitHub if you find it useful
About the Author
Sayed Moataz – Flutter developer passionate about building beautiful, responsive cross‑platform applications. This package was born from real‑world needs — solving responsive design challenges in multiple production projects.
- 💼 LinkedIn:
- 🐙 GitHub:
- 📧 Email:
Related Articles
- 📱 Flutter App Startup: From 30 seconds to under 1 second
- 🔔 Building a Robust Notification Status Service in Flutter
- 📊 Building a Robust Firebase Analytics Layer in Flutter
Happy coding! 🚀
If you found this article helpful, give it a ❤️ and follow for more Flutter content!