getResolution method

  1. @override
Future<Size?> getResolution()
override

Method to get device display resolution in pixels

Implementation

@override
Future<Size?> getResolution() async {
  final size = await methodChannel
      .invokeMethod<Map<Object?, Object?>>('getResolution');
  return switch (size) {
    {'width': 0, 'height': 0} => null,
    {'width': final num width, 'height': final num height} =>
      Size(width.toDouble(), height.toDouble()),
    _ => null
  };
}