pickMedia method

Future<TransferPickedFile?> pickMedia({
  1. TransferMediaType mediaType = TransferMediaType.any,
})

Prompts the user to select a single photo or video using the system photo picker.

Set mediaType to TransferMediaType.imageOnly for photos only, TransferMediaType.videoOnly for videos only, or TransferMediaType.any for both. Returns null if the user cancelled the picker.

Implementation

Future<TransferPickedFile?> pickMedia({
  TransferMediaType mediaType = TransferMediaType.any,
}) async {
  final platformFile = await _platform.pickMedia(mediaType: mediaType);
  if (platformFile == null) return null;
  return TransferPickedFile(
    path: platformFile.path,
    name: platformFile.name,
    size: platformFile.size,
    mimeType: platformFile.mimeType,
  );
}