takePhoto method

  1. @override
Future<AdaptiveFile?> takePhoto(
  1. PickerOptions options
)
override

Captures a photo using the device camera.

Implementation

@override
Future<AdaptiveFile?> takePhoto(PickerOptions options) async {
  final result = await methodChannel.invokeMethod<dynamic>(
    'takePhoto',
    {
      'preferredCameraDevice': options.preferredCameraDevice.name,
    },
  );

  if (result == null) {
    return null;
  }

  if (result is Map) {
    return AdaptiveFile.fromMap(result);
  } else if (result is String) {
    return AdaptiveFile.fromPath(result);
  } else {
    throw FormatException('Unexpected result type from takePhoto: ${result.runtimeType}');
  }
}