tryParse static method
Parses a raw platform event. Returns null for anything malformed so a
bad native payload can never crash a listener.
Implementation
static ScreenCaptureEvent? tryParse(Object? raw) {
if (raw is! Map) return null;
final type = raw['type'];
if (type == 'screenshot') return const ScreenCaptureEvent.screenshot();
if (type == 'captureChanged') {
final captured = raw['isCaptured'];
if (captured is bool) {
return ScreenCaptureEvent.captureChanged(isCaptured: captured);
}
}
return null;
}