@@ -8,30 +8,26 @@ import 'dart:ui' as ui;
88
99class ScreenUtil {
1010 static const Size defaultSize = Size (1080 , 1920 );
11- static ScreenUtil _instance;
11+ static late ScreenUtil _instance;
1212
1313 /// UI设计中手机尺寸 , px
1414 /// Size of the phone in UI Design , px
15- Size uiSize;
15+ late Size uiSize;
1616
1717 /// 控制字体是否要根据系统的“字体大小”辅助选项来进行缩放。默认值为false。
1818 /// allowFontScaling Specifies whether fonts should scale to respect Text Size accessibility settings. The default is false.
19- bool allowFontScaling;
19+ late bool allowFontScaling;
2020
21- static double _pixelRatio;
22- static double _textScaleFactor;
23- static double _screenWidth;
24- static double _screenHeight;
25- static double _statusBarHeight;
26- static double _bottomBarHeight;
21+ static late double _pixelRatio;
22+ static late double _textScaleFactor;
23+ static late double _screenWidth;
24+ static late double _screenHeight;
25+ static late double _statusBarHeight;
26+ static late double _bottomBarHeight;
2727
2828 ScreenUtil ._();
2929
3030 factory ScreenUtil () {
31- assert (
32- _instance != null ,
33- '\n Ensure to initialize ScreenUtil before accessing it.\n Please execute the init method : ScreenUtil.init()' ,
34- );
3531 return _instance;
3632 }
3733
@@ -40,7 +36,7 @@ class ScreenUtil {
4036 Size designSize = defaultSize,
4137 bool allowFontScaling = false ,
4238 }) {
43- _instance ?? = ScreenUtil ._();
39+ _instance = ScreenUtil ._();
4440 _instance
4541 ..uiSize = designSize
4642 ..allowFontScaling = allowFontScaling;
@@ -116,7 +112,7 @@ class ScreenUtil {
116112 ///Font size adaptation method
117113 ///- [fontSize] The size of the font on the UI design, in px.
118114 ///- [allowFontScaling]
119- double setSp (num fontSize, {bool allowFontScalingSelf}) =>
115+ double setSp (num fontSize, {bool ? allowFontScalingSelf}) =>
120116 allowFontScalingSelf == null
121117 ? (allowFontScaling
122118 ? (fontSize * scaleText)
0 commit comments