ScreenUtil class
Main ScreenUtil class for handling responsive design Initialize once in your app with ScreenUtil.init(context)
Properties
- appBarHeight → double
-
App bar height
no setter
- bottomBarHeight → double
-
Bottom safe area height
no setter
- contentHeight → double
-
Get usable screen height excluding app bar
no setter
- hashCode → int
-
The hash code for this object.
no setterinherited
- isDesktop → bool
-
Is desktop (width >= 900dp)
no setter
- isLandscape → bool
-
Is landscape mode
no setter
- isLargePhone → bool
-
Is large phone (width >= 400dp)
no setter
- isPhone → bool
-
Is phone (width < 600dp)
no setter
- isPortrait → bool
-
Is portrait mode
no setter
- isSmallPhone → bool
-
Is small phone (width < 360dp)
no setter
- isTablet → bool
-
Is tablet (600dp <= width < 900dp)
no setter
- orientation → Orientation
-
Current orientation
no setter
- pixelRatio → double
-
Pixel ratio
no setter
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- scaleHeight → double
-
Ratio of actual height to design height
no setter
- scaleText → double
-
Ratio of text scale
no setter
- scaleWidth → double
-
Ratio of actual width to design width
no setter
- screenHeight → double
-
Screen height in logical pixels
no setter
- screenHeightPx → double
-
Screen height in physical pixels
no setter
- screenWidth → double
-
Screen width in logical pixels
no setter
- screenWidthPx → double
-
Screen width in physical pixels
no setter
- statusBarHeight → double
-
Status bar height
no setter
- textScaleFactor → TextScaler
-
Text scale factor
no setter
- usableHeight → double
-
Get usable screen height (excluding status bar and bottom bar)
no setter
Methods
-
heightPercent(
num percent) → double - Get percentage of screen height
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
radius(
num radius) → double - Set radius with proper scaling
-
setHeight(
num height) → double - Set height based on design draft
-
setSize(
num size) → double - Set size using the smaller of width/height ratio Useful for square elements like icons
-
setSp(
num fontSize, {bool allowFontScaling = ScreenUtil.allowFontScaling}) → double - Set font size based on design draft
-
setWidth(
num width) → double - Set width based on design draft
-
toString(
) → String -
A string representation of this object.
inherited
-
widthPercent(
num percent) → double - Get percentage of screen width
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Static Properties
Static Methods
-
h(
num height) → double -
init(
BuildContext context, {double designWidth = 375, double designHeight = 812}) → void - Initialize ScreenUtil Must be called before using any responsive methods
-
r(
num radius) → double -
size(
num size) → double -
sp(
num fontSize, {bool allowFontScaling = ScreenUtil.allowFontScaling}) → double -
w(
num width) → double
Constants
- allowFontScaling → const bool
- defaultHeight → const int
- defaultWidth → const int