Showing
2 changed files
with
12 additions
and
9 deletions
@@ -141,8 +141,9 @@ class ScreenUtil { | @@ -141,8 +141,9 @@ class ScreenUtil { | ||
141 | bool minTextAdapt = false, | 141 | bool minTextAdapt = false, |
142 | FontSizeResolver? fontSizeResolver, | 142 | FontSizeResolver? fontSizeResolver, |
143 | }) { | 143 | }) { |
144 | + final view = View.maybeOf(context); | ||
144 | return configure( | 145 | return configure( |
145 | - data: MediaQuery.maybeOf(context), | 146 | + data: view != null ? MediaQueryData.fromView(view) : null, |
146 | designSize: designSize, | 147 | designSize: designSize, |
147 | splitScreenMode: splitScreenMode, | 148 | splitScreenMode: splitScreenMode, |
148 | minTextAdapt: minTextAdapt, | 149 | minTextAdapt: minTextAdapt, |
@@ -158,8 +159,8 @@ class ScreenUtil { | @@ -158,8 +159,8 @@ class ScreenUtil { | ||
158 | FontSizeResolver? fontSizeResolver, | 159 | FontSizeResolver? fontSizeResolver, |
159 | }) { | 160 | }) { |
160 | return ScreenUtil.ensureScreenSize().then((_) { | 161 | return ScreenUtil.ensureScreenSize().then((_) { |
161 | - return configure( | ||
162 | - data: MediaQuery.maybeOf(context), | 162 | + return init( |
163 | + context, | ||
163 | designSize: designSize, | 164 | designSize: designSize, |
164 | minTextAdapt: minTextAdapt, | 165 | minTextAdapt: minTextAdapt, |
165 | splitScreenMode: splitScreenMode, | 166 | splitScreenMode: splitScreenMode, |
@@ -251,8 +252,11 @@ class ScreenUtil { | @@ -251,8 +252,11 @@ class ScreenUtil { | ||
251 | if (kIsWeb) { | 252 | if (kIsWeb) { |
252 | deviceType = DeviceType.web; | 253 | deviceType = DeviceType.web; |
253 | } else { | 254 | } else { |
254 | - bool isMobile = defaultTargetPlatform == TargetPlatform.iOS || defaultTargetPlatform == TargetPlatform.android; | ||
255 | - bool isTablet = (orientation == Orientation.portrait && screenWidth >= 600) || (orientation == Orientation.landscape && screenHeight >= 600); | 255 | + bool isMobile = defaultTargetPlatform == TargetPlatform.iOS || |
256 | + defaultTargetPlatform == TargetPlatform.android; | ||
257 | + bool isTablet = | ||
258 | + (orientation == Orientation.portrait && screenWidth >= 600) || | ||
259 | + (orientation == Orientation.landscape && screenHeight >= 600); | ||
256 | 260 | ||
257 | if (isMobile) { | 261 | if (isMobile) { |
258 | deviceType = isTablet ? DeviceType.tablet : DeviceType.mobile; | 262 | deviceType = isTablet ? DeviceType.tablet : DeviceType.mobile; |
@@ -126,10 +126,9 @@ class _ScreenUtilInitState extends State<ScreenUtilInit> | @@ -126,10 +126,9 @@ class _ScreenUtilInitState extends State<ScreenUtilInit> | ||
126 | } | 126 | } |
127 | 127 | ||
128 | MediaQueryData? _newData() { | 128 | MediaQueryData? _newData() { |
129 | - MediaQueryData? mq = MediaQuery.maybeOf(context); | ||
130 | - if (mq == null) mq = MediaQueryData.fromView(View.of(context)); | ||
131 | - | ||
132 | - return mq; | 129 | + final view = View.maybeOf(context); |
130 | + if (view != null) return MediaQueryData.fromView(view); | ||
131 | + return null; | ||
133 | } | 132 | } |
134 | 133 | ||
135 | Future<void> _validateSize() async { | 134 | Future<void> _validateSize() async { |
-
Please register or login to post a comment