parseAndroidSwipeScreen function

({int height, int width})? parseAndroidSwipeScreen(
  1. String dump
)

Reads the current display-0 input frame, already rotated and accounting for resolution overrides. Refuses unknown dumps rather than using portrait wm size.

Implementation

({int width, int height})? parseAndroidSwipeScreen(String dump) {
  final match = RegExp(r'Viewport[^\n]*\bdisplayId=0,[^\n]*logicalFrame=\[0,\s*0,\s*(\d+),\s*(\d+)\]').firstMatch(dump);
  if (match == null) return null;
  final width = int.tryParse(match.group(1)!);
  final height = int.tryParse(match.group(2)!);
  if (width == null || height == null || width <= 0 || height <= 0) return null;
  return (width: width, height: height);
}