Skip to content

Commit cfd23c5

Browse files
committed
chore: fix lint issues
1 parent 1b0157e commit cfd23c5

File tree

2 files changed

+22
-8
lines changed

2 files changed

+22
-8
lines changed

lib/src/window_manager.dart

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,12 @@ class WindowManager {
8787
_listeners.remove(listener);
8888
}
8989

90+
double getDevicePixelRatio() {
91+
// Subsequent version, remove this deprecated member.
92+
// ignore: deprecated_member_use
93+
return window.devicePixelRatio;
94+
}
95+
9096
Future<void> ensureInitialized() async {
9197
await _channel.invokeMethod('ensureInitialized');
9298
}
@@ -289,7 +295,7 @@ class WindowManager {
289295
/// Returns `Rect` - The bounds of the window as Object.
290296
Future<Rect> getBounds() async {
291297
final Map<String, dynamic> arguments = {
292-
'devicePixelRatio': window.devicePixelRatio,
298+
'devicePixelRatio': getDevicePixelRatio(),
293299
};
294300
final Map<dynamic, dynamic> resultData = await _channel.invokeMethod(
295301
'getBounds',
@@ -312,7 +318,7 @@ class WindowManager {
312318
bool animate = false,
313319
}) async {
314320
final Map<String, dynamic> arguments = {
315-
'devicePixelRatio': window.devicePixelRatio,
321+
'devicePixelRatio': getDevicePixelRatio(),
316322
'x': bounds?.topLeft.dx ?? position?.dx,
317323
'y': bounds?.topLeft.dy ?? position?.dy,
318324
'width': bounds?.size.width ?? size?.width,
@@ -355,7 +361,7 @@ class WindowManager {
355361
/// Sets the minimum size of window to `width` and `height`.
356362
Future<void> setMinimumSize(Size size) async {
357363
final Map<String, dynamic> arguments = {
358-
'devicePixelRatio': window.devicePixelRatio,
364+
'devicePixelRatio': getDevicePixelRatio(),
359365
'width': size.width,
360366
'height': size.height,
361367
};
@@ -365,7 +371,7 @@ class WindowManager {
365371
/// Sets the maximum size of window to `width` and `height`.
366372
Future<void> setMaximumSize(Size size) async {
367373
final Map<String, dynamic> arguments = {
368-
'devicePixelRatio': window.devicePixelRatio,
374+
'devicePixelRatio': getDevicePixelRatio(),
369375
'width': size.width,
370376
'height': size.height,
371377
};

test/window_manager_test.dart

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,20 @@ void main() {
88
TestWidgetsFlutterBinding.ensureInitialized();
99

1010
setUp(() {
11-
channel.setMockMethodCallHandler((MethodCall methodCall) async {
12-
return '42';
13-
});
11+
TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger
12+
.setMockMethodCallHandler(
13+
channel,
14+
(MethodCall methodCall) async {
15+
return '42';
16+
},
17+
);
1418
});
1519

1620
tearDown(() {
17-
channel.setMockMethodCallHandler(null);
21+
TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger
22+
.setMockMethodCallHandler(
23+
channel,
24+
null,
25+
);
1826
});
1927
}

0 commit comments

Comments
 (0)