@@ -92,16 +92,13 @@ class ScreenUtil {
92
92
}
93
93
}
94
94
95
- static Future < void > configure ({
95
+ static void configure ({
96
96
MediaQueryData ? data,
97
97
Size ? designSize,
98
98
bool ? splitScreenMode,
99
99
bool ? minTextAdapt,
100
- bool ? ensureScreenHasSize,
101
100
FontSizeResolver ? fontSizeResolver,
102
- }) async {
103
- if (ensureScreenHasSize ?? false ) await ScreenUtil .ensureScreenSize ();
104
-
101
+ }) {
105
102
try {
106
103
if (data != null )
107
104
_instance._data = data;
@@ -135,24 +132,40 @@ class ScreenUtil {
135
132
}
136
133
137
134
/// Initializing the library.
138
- static Future < void > init (
135
+ static void init (
139
136
BuildContext context, {
140
137
Size designSize = defaultSize,
141
138
bool splitScreenMode = false ,
142
139
bool minTextAdapt = false ,
143
- bool ensureScreenSize = false ,
144
140
FontSizeResolver ? fontSizeResolver,
145
141
}) {
146
142
return configure (
147
143
data: MediaQuery .maybeOf (context),
148
144
designSize: designSize,
149
- minTextAdapt: minTextAdapt,
150
145
splitScreenMode: splitScreenMode,
151
- ensureScreenHasSize : ensureScreenSize ,
146
+ minTextAdapt : minTextAdapt ,
152
147
fontSizeResolver: fontSizeResolver,
153
148
);
154
149
}
155
150
151
+ static Future <void > ensureScreenSizeAndInit (
152
+ BuildContext context, {
153
+ Size designSize = defaultSize,
154
+ bool splitScreenMode = false ,
155
+ bool minTextAdapt = false ,
156
+ FontSizeResolver ? fontSizeResolver,
157
+ }) {
158
+ return ScreenUtil .ensureScreenSize ().then ((_) {
159
+ return configure (
160
+ data: MediaQuery .maybeOf (context),
161
+ designSize: designSize,
162
+ minTextAdapt: minTextAdapt,
163
+ splitScreenMode: splitScreenMode,
164
+ fontSizeResolver: fontSizeResolver,
165
+ );
166
+ });
167
+ }
168
+
156
169
///获取屏幕方向
157
170
///Get screen orientation
158
171
Orientation get orientation => _orientation;
0 commit comments