toggleRecording method

Future<void> toggleRecording()

Implementation

Future<void> toggleRecording() async {
  if (controller.value.isRecording) {
    final UArRecording? recording = await controller.stopRecording();
    if (recording == null) return;
    if (widget.onRecorded != null) {
      widget.onRecorded!(recording);
    } else if (_o.shareSnapshots) {
      final String? path = recording.path;
      final Uint8List? bytes = recording.bytes;
      if (path != null) {
        await UShare.file(path: path);
      } else if (bytes != null) {
        await UShare.bytes(bytes: bytes, fileName: "ar_${DateTime.now().millisecondsSinceEpoch}.webm", mimeType: recording.mimeType);
      }
    }
  } else {
    await controller.startRecording(audio: !kIsWeb);
  }
}