|
@@ -57,42 +57,44 @@ class AppConfigService extends _$AppConfigService {
|
|
|
}
|
|
|
|
|
|
void initSize(BuildContext context) {
|
|
|
- //屏幕大小
|
|
|
- final size = MediaQuery.of(context).size;
|
|
|
- //密度
|
|
|
- final ratio = MediaQuery.of(context).devicePixelRatio;
|
|
|
- //设备像素 px
|
|
|
- final width = size.width * ratio;
|
|
|
- final height = size.height * ratio;
|
|
|
+ if (state.mSize == null) {
|
|
|
+ //屏幕大小
|
|
|
+ final size = MediaQuery.of(context).size;
|
|
|
+ //密度
|
|
|
+ final ratio = MediaQuery.of(context).devicePixelRatio;
|
|
|
+ //设备像素 px
|
|
|
+ final width = size.width * ratio;
|
|
|
+ final height = size.height * ratio;
|
|
|
|
|
|
- var configState = state.copyWith(
|
|
|
- mSize: size,
|
|
|
- mRatio: ratio,
|
|
|
- width: width,
|
|
|
- height: height,
|
|
|
- whRatio: height / width,
|
|
|
- isFullScreenDevice: (height / width) > 1.9,
|
|
|
- topPadding: MediaQuery.of(context).padding.top,
|
|
|
- bottomPadding: MediaQuery.of(context).padding.bottom,
|
|
|
- textScaleFactor: MediaQuery.of(context).textScaleFactor,
|
|
|
- platformBrightness: MediaQuery.of(context).platformBrightness,
|
|
|
- viewInsets: MediaQuery.of(context).viewInsets,
|
|
|
- padding: MediaQuery.of(context).padding,
|
|
|
- alwaysUse24HourFormat: MediaQuery.of(context).alwaysUse24HourFormat,
|
|
|
- accessibleNavigation: MediaQuery.of(context).accessibleNavigation,
|
|
|
- invertColors: MediaQuery.of(context).invertColors,
|
|
|
- disableAnimations: MediaQuery.of(context).disableAnimations,
|
|
|
- boldText: MediaQuery.of(context).boldText,
|
|
|
- orientation: MediaQuery.of(context).orientation,
|
|
|
- density: MediaQuery.devicePixelRatioOf(context),
|
|
|
- );
|
|
|
+ var configState = state.copyWith(
|
|
|
+ mSize: size,
|
|
|
+ mRatio: ratio,
|
|
|
+ width: width,
|
|
|
+ height: height,
|
|
|
+ whRatio: height / width,
|
|
|
+ isFullScreenDevice: (height / width) > 1.9,
|
|
|
+ topPadding: MediaQuery.of(context).padding.top,
|
|
|
+ bottomPadding: MediaQuery.of(context).padding.bottom,
|
|
|
+ textScaleFactor: MediaQuery.of(context).textScaleFactor,
|
|
|
+ platformBrightness: MediaQuery.of(context).platformBrightness,
|
|
|
+ viewInsets: MediaQuery.of(context).viewInsets,
|
|
|
+ padding: MediaQuery.of(context).padding,
|
|
|
+ alwaysUse24HourFormat: MediaQuery.of(context).alwaysUse24HourFormat,
|
|
|
+ accessibleNavigation: MediaQuery.of(context).accessibleNavigation,
|
|
|
+ invertColors: MediaQuery.of(context).invertColors,
|
|
|
+ disableAnimations: MediaQuery.of(context).disableAnimations,
|
|
|
+ boldText: MediaQuery.of(context).boldText,
|
|
|
+ orientation: MediaQuery.of(context).orientation,
|
|
|
+ density: MediaQuery.devicePixelRatioOf(context),
|
|
|
+ );
|
|
|
|
|
|
- state = configState;
|
|
|
+ state = configState;
|
|
|
|
|
|
- //初始化Flustarts工具类中 ScreenUtils 工具,可以设置设计稿的大小,可以选择性的使用 getAdapterSizeCtx 适配大小屏不同尺寸的展示
|
|
|
- setDesignWHD(375, 667, density: configState.density);
|
|
|
+ //初始化Flustarts工具类中 ScreenUtils 工具,可以设置设计稿的大小,可以选择性的使用 getAdapterSizeCtx 适配大小屏不同尺寸的展示
|
|
|
+ setDesignWHD(375, 667, density: configState.density);
|
|
|
|
|
|
- printAppConfig();
|
|
|
+ printAppConfig();
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
/// 测试并打印数据
|