Showing
1 changed file
with
4 additions
and
2 deletions
@@ -63,11 +63,13 @@ class ScreenUtil { | @@ -63,11 +63,13 @@ class ScreenUtil { | ||
63 | 63 | ||
64 | /// 当前设备宽度 dp | 64 | /// 当前设备宽度 dp |
65 | /// The horizontal extent of this size. | 65 | /// The horizontal extent of this size. |
66 | - double get screenWidth => _screenWidth; | 66 | + double get screenWidth => |
67 | + context == null ? _screenWidth : MediaQuery.of(context!).size.width; | ||
67 | 68 | ||
68 | ///当前设备高度 dp | 69 | ///当前设备高度 dp |
69 | ///The vertical extent of this size. dp | 70 | ///The vertical extent of this size. dp |
70 | - double get screenHeight => _screenHeight; | 71 | + double get screenHeight => |
72 | + context == null ? _screenHeight : MediaQuery.of(context!).size.height; | ||
71 | 73 | ||
72 | /// 状态栏高度 dp 刘海屏会更高 | 74 | /// 状态栏高度 dp 刘海屏会更高 |
73 | /// The offset from the top, in dp | 75 | /// The offset from the top, in dp |
-
Please register or login to post a comment