pickAudio method

Future<PickedFile?> pickAudio({
  1. bool withData = false,
})

Picks a single audio file from the device storage.

withData includes file bytes in the result when set to true.

Returns a PickedFile object or null if no audio file was selected.

Supported formats: MP3, WAV, M4A, FLAC, OGG, AAC, WMA, AIFF

Example:

final audio = await ImagePickerMaster.instance.pickAudio();
if (audio != null) {
  print('Selected audio: ${audio.name}');
  print('MIME type: ${audio.mimeType}');
}

Implementation

Future<PickedFile?> pickAudio({bool withData = false}) async {
  final result = await pickFiles(
    type: FileType.audio,
    allowMultiple: false,
    withData: withData,
  );

  return result?.isNotEmpty == true ? result!.first : null;
}