ScreenUtil class

Responsive sizing utility.

Initialise once in your root widget:

ScreenUtil.init(context, designWidth: 390, designHeight: 844);

Then use anywhere:

SizedBox(width: 16.w, height: 24.h)
Text('Hello', style: TextStyle(fontSize: 14.sp))
BorderRadius.circular(8.r)

Properties

hashCode int
The hash code for this object.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited

Static Properties

pixelRatio double
no setter
screenHeight double
no setter
screenWidth double
no setter

Static Methods

h(double value) double
Scales a height value relative to the design height.
init(BuildContext context, {double designWidth = 390, double designHeight = 844}) → void
r(double value) double
Scales a radius value (same as w).
sp(double value) double
Scales a font size using the smaller of width/height ratios.
w(double value) double
Scales a width value relative to the design width.