File tree Expand file tree Collapse file tree 2 files changed +23
-11
lines changed Expand file tree Collapse file tree 2 files changed +23
-11
lines changed Original file line number Diff line number Diff line change @@ -35,16 +35,23 @@ class ScreenUtil {
35
35
}
36
36
37
37
static void init (
38
- BoxConstraints constraints, {
38
+ BoxConstraints constraints,
39
+ Orientation orientation,
40
+ {
39
41
Size designSize = defaultSize,
40
42
bool allowFontScaling = false ,
41
43
}) {
42
44
_instance = ScreenUtil ._();
43
45
_instance
44
46
..uiSize = designSize
45
47
..allowFontScaling = allowFontScaling;
46
- _screenWidth = constraints.maxWidth;
48
+ if (orientation == Orientation .potrait){
49
+ _screenWidth = constraints.maxWidth;
47
50
_screenHeight = constraints.maxHeight;
51
+ }else {
52
+ _screenWidth = constraints.maxHeight;
53
+ _screenHeight = constraints.maxWidth;
54
+ }
48
55
49
56
var window = WidgetsBinding .instance? .window ?? ui.window;
50
57
_pixelRatio = window.devicePixelRatio;
Original file line number Diff line number Diff line change @@ -22,16 +22,21 @@ class ScreenUtilInit extends StatelessWidget {
22
22
@override
23
23
Widget build (BuildContext context) {
24
24
return LayoutBuilder (
25
- // ignore: missing_return
26
25
builder: (_, BoxConstraints constraints) {
27
- if (constraints.maxWidth != 0 ) {
28
- ScreenUtil .init (
29
- constraints,
30
- designSize: designSize,
31
- allowFontScaling: allowFontScaling,
32
- );
33
- }
34
- return builder ();
26
+ return OrientationBuilder (
27
+ builder: (_, Orientation orientation) {
28
+ // ignore: missing_return
29
+ if (constraints.maxWidth != 0 ) {
30
+ ScreenUtil .init (
31
+ constraints,
32
+ orientation,
33
+ designSize: designSize,
34
+ allowFontScaling: allowFontScaling,
35
+ );
36
+ }
37
+ return builder ();
38
+ },
39
+ );
35
40
},
36
41
);
37
42
}
You can’t perform that action at this time.
0 commit comments