Showing
1 changed file
with
21 additions
and
8 deletions
@@ -92,16 +92,13 @@ class ScreenUtil { | @@ -92,16 +92,13 @@ class ScreenUtil { | ||
92 | } | 92 | } |
93 | } | 93 | } |
94 | 94 | ||
95 | - static Future<void> configure({ | 95 | + static void configure({ |
96 | MediaQueryData? data, | 96 | MediaQueryData? data, |
97 | Size? designSize, | 97 | Size? designSize, |
98 | bool? splitScreenMode, | 98 | bool? splitScreenMode, |
99 | bool? minTextAdapt, | 99 | bool? minTextAdapt, |
100 | - bool? ensureScreenHasSize, | ||
101 | FontSizeResolver? fontSizeResolver, | 100 | FontSizeResolver? fontSizeResolver, |
102 | - }) async { | ||
103 | - if (ensureScreenHasSize ?? false) await ScreenUtil.ensureScreenSize(); | ||
104 | - | 101 | + }) { |
105 | try { | 102 | try { |
106 | if (data != null) | 103 | if (data != null) |
107 | _instance._data = data; | 104 | _instance._data = data; |
@@ -135,22 +132,38 @@ class ScreenUtil { | @@ -135,22 +132,38 @@ class ScreenUtil { | ||
135 | } | 132 | } |
136 | 133 | ||
137 | /// Initializing the library. | 134 | /// Initializing the library. |
138 | - static Future<void> init( | 135 | + static void init( |
136 | + BuildContext context, { | ||
137 | + Size designSize = defaultSize, | ||
138 | + bool splitScreenMode = false, | ||
139 | + bool minTextAdapt = false, | ||
140 | + FontSizeResolver? fontSizeResolver, | ||
141 | + }) { | ||
142 | + return configure( | ||
143 | + data: MediaQuery.maybeOf(context), | ||
144 | + designSize: designSize, | ||
145 | + splitScreenMode: splitScreenMode, | ||
146 | + minTextAdapt: minTextAdapt, | ||
147 | + fontSizeResolver: fontSizeResolver, | ||
148 | + ); | ||
149 | + } | ||
150 | + | ||
151 | + static Future<void> ensureScreenSizeAndInit( | ||
139 | BuildContext context, { | 152 | BuildContext context, { |
140 | Size designSize = defaultSize, | 153 | Size designSize = defaultSize, |
141 | bool splitScreenMode = false, | 154 | bool splitScreenMode = false, |
142 | bool minTextAdapt = false, | 155 | bool minTextAdapt = false, |
143 | - bool ensureScreenSize = false, | ||
144 | FontSizeResolver? fontSizeResolver, | 156 | FontSizeResolver? fontSizeResolver, |
145 | }) { | 157 | }) { |
158 | + return ScreenUtil.ensureScreenSize().then((_) { | ||
146 | return configure( | 159 | return configure( |
147 | data: MediaQuery.maybeOf(context), | 160 | data: MediaQuery.maybeOf(context), |
148 | designSize: designSize, | 161 | designSize: designSize, |
149 | minTextAdapt: minTextAdapt, | 162 | minTextAdapt: minTextAdapt, |
150 | splitScreenMode: splitScreenMode, | 163 | splitScreenMode: splitScreenMode, |
151 | - ensureScreenHasSize: ensureScreenSize, | ||
152 | fontSizeResolver: fontSizeResolver, | 164 | fontSizeResolver: fontSizeResolver, |
153 | ); | 165 | ); |
166 | + }); | ||
154 | } | 167 | } |
155 | 168 | ||
156 | ///获取屏幕方向 | 169 | ///获取屏幕方向 |
-
Please register or login to post a comment