ScreenUtil class
Constructors
- ScreenUtil()
-
工厂构造函数,返回单例实例
factory
Properties
- bottomBarHeight → double
-
获取底部安全区距离
no setter
- fontSizeResolver ↔ FontSizeResolver?
-
字体大小解析器
getter/setter pair
- hashCode → int
-
The hash code for this object.
no setterinherited
- orientation → Orientation
-
获取屏幕方向
no setter
- pixelRatio → double?
-
获取文本缩放因子
no setter
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- scaleHeight → double
-
获取实际高度与UI设计高度的比例
no setter
- scaleText → double
-
获取文本缩放比例
no setter
- scaleWidth → double
-
获取实际宽度与UI设计宽度的比例
no setter
- screenHeight → double
-
获取当前设备高度
no setter
- screenWidth → double
-
获取当前设备宽度
no setter
- statusBarHeight → double
-
获取状态栏高度
no setter
Methods
-
deviceType(
BuildContext context) → DeviceType - 获取设备类型
-
diagonal(
num d) → double - 根据宽度和高度同时进行适配
-
diameter(
num d) → double - 根据宽度和高度的最大值进行适配
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
radius(
num r) → double - 根据宽度或高度中的较小值进行适配
-
setHeight(
num height) → double - 根据UI设计的设备高度适配尺寸
-
setHorizontalSpacing(
num width) → SizedBox - 创建水平间距
-
setHorizontalSpacingDiagonal(
num width) → SizedBox - 创建基于对角线的水平间距
-
setHorizontalSpacingDiameter(
num width) → SizedBox - 创建基于直径的水平间距
-
setHorizontalSpacingRadius(
num width) → SizedBox - 创建基于半径的水平间距
-
setSp(
num fontSize) → double - 字体大小适配方法
-
setVerticalSpacing(
num height) → SizedBox - 创建垂直间距
-
setVerticalSpacingDiagonal(
num height) → SizedBox - 创建基于对角线的垂直间距
-
setVerticalSpacingDiameter(
num height) → SizedBox - 创建基于直径的垂直间距
-
setVerticalSpacingFromWidth(
num height) → SizedBox - 创建基于宽度的垂直间距
-
setVerticalSpacingRadius(
num height) → SizedBox - 创建基于半径的垂直间距
-
setWidth(
num width) → double - 根据UI设计的设备宽度适配尺寸
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Static Methods
-
configure(
{MediaQueryData? data, Size? designSize, bool? splitScreenMode, bool? minTextAdapt, FontSizeResolver? fontSizeResolver}) → void - 配置 ScreenUtil 实例
-
enableScale(
{bool enableWH()?, bool enableText()?}) → void - 启用或禁用缩放
-
ensureScreenSize(
[FlutterView? window, Duration duration = const Duration(milliseconds: 10)]) → Future< void> - 手动等待窗口大小初始化
-
ensureScreenSizeAndInit(
BuildContext context, {Size designSize = defaultSize, bool splitScreenMode = false, bool minTextAdapt = false, FontSizeResolver? fontSizeResolver}) → Future< void> - 确保屏幕尺寸已初始化,然后初始化 ScreenUtil
-
init(
BuildContext context, {Size designSize = defaultSize, bool splitScreenMode = false, bool minTextAdapt = false, FontSizeResolver? fontSizeResolver}) → void - 初始化 ScreenUtil 库
-
registerToBuild(
BuildContext context, [bool withDescendants = false]) → void - 注册当前页面及其所有后代以进行重建 在构建 Web 和桌面应用时特别有用
Constants
- defaultSize → const Size
- 默认设计尺寸