actionHandler method
Future<CameraInternalMedia?>
actionHandler(
- CameraController cameraController,
- Completer<
CameraInternalMedia> completer, { - required Future<
ImageLocation> locationData(), - required DateTime dateTime,
- required DeviceOrientation orientation,
override
Implementation
@override
Future<CameraInternalMedia?> actionHandler(
CameraController cameraController,
Completer<CameraInternalMedia> completer, {
required final Future<ImageLocation> Function() locationData,
required DateTime dateTime,
required DeviceOrientation orientation,
}) async {
isCapturing.value = true;
if (!cameraController.value.isInitialized) {
if (kDebugMode) {
print('Error: select a camera first.');
}
throw Exception('Camera controller not init.');
}
if (cameraController.value.isRecordingVideo) {
if (kDebugMode) {
print('A recording is already started, do nothing.');
}
throw Exception('Video Recording Under Process.');
}
try {
// await controller.setFlashMode(FlashMode.off);
final image = await cameraController.takePicture();
completer.complete(
CameraInternalImage(
imageFile: image,
locationData: await locationData.call(),
dateTime: dateTime,
orientation: orientation,
),
);
cameraModuleCallbacks?.onCapture.call();
await cameraController.pausePreview();
return completer.future;
} catch (e, s) {
log('Capture error', stackTrace: s, error: e);
rethrow;
} finally {
isCapturing.value = false;
}
}