
Responsive Widgets Prefix allows you to add the “Responsive” prefix to any widget that needs scaling or font size increases (for varying device screen sizes).
Features
When not using Responsive widgets, you can run into issues with scaling like the following:
Non Responsive Text
Default ResponsiveText
Customized ResponsiveText (scaleMediumTablet)
Note: The following widgets are currently supported, but we welcome widget requests for new responsive widgets.
Visual | Structural | Interactive | Platform |
---|---|---|---|
AssetImage | Container | IconButton | MaterialApp |
Text | Padding | FloatingActionButton | CupertinoApp |
Card | ButtonTheme | AppBar | |
Icon | |||
Getting started
Install Responsive Widgets Prefix
flutter pub get responsive_widgets_prefix
Or install Responsive Widgets Prefix (in pubspec.yaml)
Add Responsive Widgets Prefix import
import 'package:responsive_widgets_prefix/responsive_widgets_prefix.dart';
Finally, create a Responsive App
In the case of a MaterialApp, all you would need to do is add the Responsive prefix.
// This widget is the root of your application.
@override
Widget build(BuildContext context) {
return ResponsiveMaterialApp(
title: 'Flutter Demo',
theme: ThemeData(
// This is the theme of your application.
//
// Try running your application with "flutter run". You'll see the
// application has a blue toolbar. Then, without quitting the app, try
// changing the primarySwatch below to Colors.green and then invoke
// "hot reload" (press "r" in the console where you ran "flutter run",
// or simply save your changes to "hot reload" in a Flutter IDE).
// Notice that the counter didn't reset back to zero; the application
// is not restarted.
primarySwatch: Colors.blue,
),
home: const MyHomePage(title: 'Flutter Demo Home Page'),
);
}
}
Note: Alternatively, if you are using a CupertinoApp the same Responsive prefix can be added.
// This widget is the root of your application.
@override
Widget build(BuildContext context) {
return ResponsiveCupertinoApp(
title: 'Flutter Demo',
theme: CupertinoThemeData(
// This is the theme of your application.
//
// Try running your application with "flutter run". You'll see the
// application has a blue toolbar. Then, without quitting the app, try
// changing the primaryColor below to Colors.green and then invoke
// "hot reload" (press "r" in the console where you ran "flutter run",
// or simply save your changes to "hot reload" in a Flutter IDE).
// Notice that the counter didn't reset back to zero; the application
// is not restarted.
primaryColor: Colors.blue,
),
home: const MyHomePage(title: 'Flutter Demo Home Page'),
);
}
}
Usage
Our first example will be the Counter Sample project. With this project we can integrate the Responsive
Widgets prefix to scale the UI, for the appropriate scren size (and preview the results).
Create platforms file (lib/platforms.dart)
Create main file (lib/main.dart)
The comparisons would look like the following:
![]() |
![]() |
![]() |
Samsung A50 |
iPhone 12 Max Pro |
iPad Pro 11 Inches |
![]() |
![]() |
![]() |
Additional information
Package Support
To support this repo, take a look at the SUPPORT.md file.
Package Documentation
To view the documentation on the package, follow this link