Committed by
GitHub
Changed window reference
I've changed reference of window object as it is recommended in windows docs. window.dart /// Please try to avoid statically referencing this and instead use a /// binding for dependency resolution such as `WidgetsBinding.instance.window`. binding.dart /// Each of these other bindings could individually access a [Window] statically, /// but that would preclude the ability to test these behaviors with a fake /// window for verification purposes. Therefore, [BindingBase] exposes this /// [Window] for use by other bindings. A subclass of [BindingBase], such as /// [TestWidgetsFlutterBinding], can override this accessor to return a /// different [Window] implementation, such as a [TestWindow].
Showing
1 changed file
with
1 additions
and
2 deletions
@@ -4,7 +4,6 @@ | @@ -4,7 +4,6 @@ | ||
4 | */ | 4 | */ |
5 | 5 | ||
6 | import 'package:flutter/material.dart'; | 6 | import 'package:flutter/material.dart'; |
7 | -import 'dart:ui' as ui; | ||
8 | 7 | ||
9 | class ScreenUtil { | 8 | class ScreenUtil { |
10 | static const Size defaultSize = Size(1080, 1920); | 9 | static const Size defaultSize = Size(1080, 1920); |
@@ -43,7 +42,7 @@ class ScreenUtil { | @@ -43,7 +42,7 @@ class ScreenUtil { | ||
43 | _screenWidth = constraints.maxWidth; | 42 | _screenWidth = constraints.maxWidth; |
44 | _screenHeight = constraints.maxHeight; | 43 | _screenHeight = constraints.maxHeight; |
45 | 44 | ||
46 | - var mediaQuery = ui.window; | 45 | + var mediaQuery = WidgetsBinding.instance.window; |
47 | _pixelRatio = mediaQuery.devicePixelRatio; | 46 | _pixelRatio = mediaQuery.devicePixelRatio; |
48 | _statusBarHeight = mediaQuery.padding.top; | 47 | _statusBarHeight = mediaQuery.padding.top; |
49 | _bottomBarHeight = mediaQuery.padding.bottom; | 48 | _bottomBarHeight = mediaQuery.padding.bottom; |
-
Please register or login to post a comment