flutter_ui_scaler
Achieve pixel-perfect scaling for your Flutter UI with ease.
π― Ensure your designs look consistent and accurate across devices, whether on phones or tablets, in portrait or landscape orientation.
β¨ Why Use This Plugin?
Flutterβs MediaQuery
scaling is not design-accurate.
Different DPIs and aspect ratios distort layouts β especially in landscape, where text suddenly becomes huge.
60px in figma is not 60px on device! Not with flutter natively.
Figma Design | With flutter_ui_scaler |
Without (native scaling) |
---|---|---|
![]() |
![]() |
![]() |
π Notice how proportions, text size, and padding stay true to the design with the plugin.
Landscape Behaviour
With | Without |
---|---|
![]() |
![]() |
β
Text scaling stays consistent
β Native scaling causes bloated titles and mismatched spacing
π¦ Installation
From terminal:
flutter pub add flutter_ui_scaler
Or add to pubspec.yaml:
dependencies:
flutter_ui_scaler: ^latest
Then import:
import 'package:flutter_ui_scaler/flutter_ui_scaler.dart';
π Quick Start
return UiScaleScope(
figmaW: 440, // your design frame width
figmaH: 956, // your design frame height
child: MaterialApp(home: MyApp()),
);
Inside widgets:
final ds = context.ds; // sugar for DesignScale.of(context)
double pad = ds.sx(16); // padding, radius, sizes
double titleSize = ds.sp(20); // font sizes
βοΈ CLI (Optional)
Team defaults can be set via CLI:
flutter_ui_scaler --set-des-res 440x956
flutter_ui_scaler --set-clamp 0.9..1.15
flutter_ui_scaler --show
This generates .flutter_ui_scaler.yaml
for shared design settings.
π§ API Overview
DesignScale.of(
context,
figmaW: 440,
figmaH: 956,
minScale: 0.9,
maxScale: 1.15,
tightFontsInLandscape: true,
);
sx
/sy
β scaling for padding, widths, radii, heights.sp
β scaling for fonts with smart landscape strategy.UiScaleScope
β app-wide configuration.context.ds
β shorthand forDesignScale.of(context)
.
π Best Practices
- β
Use
sx
/sy
for paddings, radii, widths, heights. - β
Use
sp
only for text. - π« Donβt scale bitmap images.
- π§ͺ Test on multiple screen sizes (e.g., small phones, tablets, landscape).
π Changelog
See CHANGELOG.md.
π License
MIT Β© MNBLabs