screenshot method
Implementation
@override
Future<ScreenshotResult> screenshot({
required List<String> allowedBundleIds,
int? displayId,
}) async {
final d = await getDisplaySize(displayId);
final targetDims = _computeTargetDims(d.width, d.height, d.scaleFactor);
// Use screencapture command as fallback
final tempFile = p.join(
Directory.systemTemp.path,
'screenshot_${DateTime.now().millisecondsSinceEpoch}.jpg',
);
try {
await Process.run('screencapture', ['-x', '-t', 'jpg', tempFile]);
final bytes = await File(tempFile).readAsBytes();
final b64 = base64Encode(bytes);
return ScreenshotResult(
base64: b64,
width: targetDims[0],
height: targetDims[1],
);
} finally {
try {
await File(tempFile).delete();
} catch (_) {}
}
}