capturePhoto method

  1. @override
Future<CapturedPhoto> capturePhoto(
  1. String? deviceUUID
)
override

Implementation

@override
Future<CapturedPhoto> capturePhoto(String? deviceUUID) async {
  final args = <String, dynamic>{};
  if (deviceUUID != null) {
    args['deviceUUID'] = deviceUUID;
  }
  final result = await methodChannel.invokeMapMethod<String, dynamic>(
    'capturePhoto',
    args,
  );
  if (result == null) {
    throw PlatformException(
      code: 'CAPTURE_PHOTO_FAILED',
      message: 'No photo data returned from platform.',
    );
  }
  final bytes = result['bytes'] as Uint8List?;
  final format = result['format'] as String?;
  if (bytes == null || format == null) {
    throw PlatformException(
      code: 'CAPTURE_PHOTO_FAILED',
      message: 'Invalid photo data returned from platform.',
    );
  }
  return CapturedPhoto(bytes: bytes, format: format);
}