Showing
1 changed file
with
19 additions
and
16 deletions
@@ -19,21 +19,24 @@ class ScreenUtilInit extends StatelessWidget { | @@ -19,21 +19,24 @@ class ScreenUtilInit extends StatelessWidget { | ||
19 | 19 | ||
20 | @override | 20 | @override |
21 | Widget build(BuildContext context) { | 21 | Widget build(BuildContext context) { |
22 | - return LayoutBuilder(builder: (_, BoxConstraints constraints) { | ||
23 | - if (constraints.maxWidth != 0) { | ||
24 | - final Orientation orientation = | ||
25 | - constraints.maxWidth > constraints.maxHeight | ||
26 | - ? Orientation.landscape | ||
27 | - : Orientation.portrait; | ||
28 | - ScreenUtil.init(constraints, | ||
29 | - context: _, | ||
30 | - orientation: orientation, | ||
31 | - designSize: designSize, | ||
32 | - splitScreenMode: splitScreenMode, | ||
33 | - minTextAdapt: minTextAdapt); | ||
34 | - return builder(); | ||
35 | - } | ||
36 | - return Container(); | ||
37 | - }); | 22 | + return MediaQuery( |
23 | + data: MediaQueryData.fromWindow(WidgetsBinding.instance!.window), | ||
24 | + child: LayoutBuilder(builder: (_, BoxConstraints constraints) { | ||
25 | + if (constraints.maxWidth != 0) { | ||
26 | + final Orientation orientation = | ||
27 | + constraints.maxWidth > constraints.maxHeight | ||
28 | + ? Orientation.landscape | ||
29 | + : Orientation.portrait; | ||
30 | + ScreenUtil.init(constraints, | ||
31 | + context: _, | ||
32 | + orientation: orientation, | ||
33 | + designSize: designSize, | ||
34 | + splitScreenMode: splitScreenMode, | ||
35 | + minTextAdapt: minTextAdapt); | ||
36 | + return builder(); | ||
37 | + } | ||
38 | + return Container(); | ||
39 | + }), | ||
40 | + ); | ||
38 | } | 41 | } |
39 | } | 42 | } |
-
Please register or login to post a comment