takePicture method

Future<void> takePicture()

The method to take a picture. The picture will only taken when isInitialized, and the camera is not taking pictures.

Implementation

Future<void> takePicture() async {
  if (controller.value.isInitialized && !controller.value.isTakingPicture) {
    final entity = await CameraPickerViewer.pushToViewer(
      context,
      pickerState: this,
      previewXFile: await controller.takePicture(),
      theme: theme,
      shouldDeletePreviewFile: shouldDeletePreviewFile,
      onEntitySaving: widget.onEntitySaving,
    );
    if (entity != null) {
      Navigator.of(context).pop(entity);
    } else {
      safeSetState(() {});
    }
  }
}