toFile method

File? toFile(
  1. Recording recording, {
  2. bool onlyIfPlayable = false,
})

Implementation

File? toFile(Recording recording, { bool onlyIfPlayable = false }) {
  // There could technically be an empty file that a caller would like to delete,
  // so, don't account for playable audio
  var filepath = recording.filepath;
  var isPlayable = onlyIfPlayable ? recording.isPlayable : true;
  if (recording.isStopped && filepath != null && isPlayable) {
    return file(filepath);
  } else {
    return null;
  }
}