audioPath method

Future<String?> audioPath()

Implementation

Future<String?> audioPath() async {
  if (proof != null) {
    final prefix = (proof!.before == this)
        ? 'before_audio_'
        : (proof!.after == this)
            ? 'after_audio_'
            : '';
    if (prefix == '') throw StateError("ProofEntry doesn't have parent");

    final proofList = proof!.proofList;
    final name = proof!.name;
    if (kIsWeb) {
      showErrorNotification(tr().saveTheFileInOrderToNotLoseIt);

      return safeName('${prefix}_${proofList.client}_${proofList.date}.m4a');
    }

    final dir = await proofList.proofPath(name ?? '0');
    if (dir != null) {
      return path.join(
        dir.path,
        safeName(
          '${prefix}_${proofList.client}_${proofList.date}.m4a',
        ),
      );
    }
  }

  return null;
}