李卓原

使用MediaQuery包裹LayoutBuilder

@@ -19,7 +19,9 @@ class ScreenUtilInit extends StatelessWidget { @@ -19,7 +19,9 @@ 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) { 22 + return MediaQuery(
  23 + data: MediaQueryData.fromWindow(WidgetsBinding.instance!.window),
  24 + child: LayoutBuilder(builder: (_, BoxConstraints constraints) {
23 if (constraints.maxWidth != 0) { 25 if (constraints.maxWidth != 0) {
24 final Orientation orientation = 26 final Orientation orientation =
25 constraints.maxWidth > constraints.maxHeight 27 constraints.maxWidth > constraints.maxHeight
@@ -34,6 +36,7 @@ class ScreenUtilInit extends StatelessWidget { @@ -34,6 +36,7 @@ class ScreenUtilInit extends StatelessWidget {
34 return builder(); 36 return builder();
35 } 37 }
36 return Container(); 38 return Container();
37 - }); 39 + }),
  40 + );
38 } 41 }
39 } 42 }