takeSnapshot method
Future<UCapturedPhoto?>
takeSnapshot({
- UPhotoFormat format = UPhotoFormat.jpeg,
- int quality = 90,
Grabs the current preview frame as an image without a full capture cycle. Much faster than takePhoto and silent, at preview resolution.
Implementation
Future<UCapturedPhoto?> takeSnapshot({UPhotoFormat format = UPhotoFormat.jpeg, int quality = 90}) async {
final int? id = _sessionId;
if (id == null) return null;
try {
final Map<Object?, Object?>? raw = await UCameraChannel.invokeMap("takeSnapshot", <String, Object?>{
"sessionId": id,
"format": format.name,
"quality": quality,
});
return raw == null ? null : UCapturedPhoto.fromMap(raw);
} on UCameraException catch (error) {
_fail(error);
return null;
} catch (error) {
_fail(UCameraException(code: UCameraErrorCode.unknown, message: "$error"));
return null;
}
}