takePhoto method

Future<AttachmentResult?> takePhoto({
  1. bool enableCropping = true,
})

Launches the native camera to take a single photo.

If enableCropping is true, launches the image cropper after capture. Returns null if the user cancels.

Implementation

Future<AttachmentResult?> takePhoto({bool enableCropping = true}) async {
  try {
    final String? path = await _channel.invokeMethod('takeImage');
    if (path == null) {
      return null;
    }

    final file = enableCropping ? await cropImage(path) : File(path);

    return file != null ? _resultFromPath(file.path) : null;
  } catch (e) {
    debugPrint('PixelToPdfService: takePhoto error: $e');
    return null;
  }
}