Skip to content

Commit

Permalink
chore: fix lint issues
Browse files Browse the repository at this point in the history
  • Loading branch information
lijy91 committed May 21, 2023
1 parent 1b0157e commit cfd23c5
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 8 deletions.
14 changes: 10 additions & 4 deletions lib/src/window_manager.dart
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,12 @@ class WindowManager {
_listeners.remove(listener);
}

double getDevicePixelRatio() {
// Subsequent version, remove this deprecated member.
// ignore: deprecated_member_use
return window.devicePixelRatio;
}

Future<void> ensureInitialized() async {
await _channel.invokeMethod('ensureInitialized');
}
Expand Down Expand Up @@ -289,7 +295,7 @@ class WindowManager {
/// Returns `Rect` - The bounds of the window as Object.
Future<Rect> getBounds() async {
final Map<String, dynamic> arguments = {
'devicePixelRatio': window.devicePixelRatio,
'devicePixelRatio': getDevicePixelRatio(),
};
final Map<dynamic, dynamic> resultData = await _channel.invokeMethod(
'getBounds',
Expand All @@ -312,7 +318,7 @@ class WindowManager {
bool animate = false,
}) async {
final Map<String, dynamic> arguments = {
'devicePixelRatio': window.devicePixelRatio,
'devicePixelRatio': getDevicePixelRatio(),
'x': bounds?.topLeft.dx ?? position?.dx,
'y': bounds?.topLeft.dy ?? position?.dy,
'width': bounds?.size.width ?? size?.width,
Expand Down Expand Up @@ -355,7 +361,7 @@ class WindowManager {
/// Sets the minimum size of window to `width` and `height`.
Future<void> setMinimumSize(Size size) async {
final Map<String, dynamic> arguments = {
'devicePixelRatio': window.devicePixelRatio,
'devicePixelRatio': getDevicePixelRatio(),
'width': size.width,
'height': size.height,
};
Expand All @@ -365,7 +371,7 @@ class WindowManager {
/// Sets the maximum size of window to `width` and `height`.
Future<void> setMaximumSize(Size size) async {
final Map<String, dynamic> arguments = {
'devicePixelRatio': window.devicePixelRatio,
'devicePixelRatio': getDevicePixelRatio(),
'width': size.width,
'height': size.height,
};
Expand Down
16 changes: 12 additions & 4 deletions test/window_manager_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,20 @@ void main() {
TestWidgetsFlutterBinding.ensureInitialized();

setUp(() {
channel.setMockMethodCallHandler((MethodCall methodCall) async {
return '42';
});
TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger
.setMockMethodCallHandler(
channel,
(MethodCall methodCall) async {
return '42';
},
);
});

tearDown(() {
channel.setMockMethodCallHandler(null);
TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger
.setMockMethodCallHandler(
channel,
null,
);
});
}

0 comments on commit cfd23c5

Please sign in to comment.