capture method
Future<CockpitCapturedScreenshot>
capture({
- required CockpitScreenshotRequest request,
- required CockpitCaptureProfile profile,
- CockpitSnapshot? snapshot,
Implementation
Future<CockpitCapturedScreenshot> capture({
required CockpitScreenshotRequest request,
required CockpitCaptureProfile profile,
CockpitSnapshot? snapshot,
}) async {
final payload = await _channel
.invokeMethod<Object?>('captureAcceptanceScreenshot', <String, Object?>{
'name': request.name,
'reason': request.reason.jsonValue,
'profile': profile.name,
});
if (payload is! Map<Object?, Object?>) {
throw StateError('Native capture returned an invalid payload.');
}
final bytes = payload['bytes'];
if (bytes is! Uint8List) {
throw StateError('Native capture did not return PNG bytes.');
}
return CockpitCapturedScreenshot(
artifact: CockpitArtifactRef(
role: 'screenshot',
relativePath: cockpitScreenshotRelativePathFor(request),
),
bytes: bytes,
snapshot: snapshot,
);
}