From 83b8691a311a9d886b18d012a5d9ca73d5b0c6a7 Mon Sep 17 00:00:00 2001 From: "Aamir.Muhammad" Date: Mon, 2 Jan 2023 12:16:03 +0300 Subject: [PATCH] Ios Stream Audio --- lib/provider/chat_provider_model.dart | 32 ++++++++++++++++++++------- 1 file changed, 24 insertions(+), 8 deletions(-) diff --git a/lib/provider/chat_provider_model.dart b/lib/provider/chat_provider_model.dart index a88a08c..8a91ddd 100644 --- a/lib/provider/chat_provider_model.dart +++ b/lib/provider/chat_provider_model.dart @@ -1202,19 +1202,35 @@ class ChatProviderModel with ChangeNotifier, DiagnosticableTreeMixin { void startRecoding() async { PermissionStatus status = await Permission.microphone.request(); - if (status.isDenied == true) { + if (status.isDenied) { startRecoding(); + } else if (status.isGranted) { + sRecoding(); } else { - isVoiceMsg = true; - recorderController.reset(); - await recorderController.record(path); - _recodeDuration = 0; - _startTimer(); - isRecoding = !isRecoding; - notifyListeners(); + startRecoding(); } } + // else { + // isVoiceMsg = true; + // recorderController.reset(); + // await recorderController.record(path); + // _recodeDuration = 0; + // _startTimer(); + // isRecoding = !isRecoding; + // notifyListeners(); + // } + + void sRecoding() async { + isVoiceMsg = true; + recorderController.reset(); + await recorderController.record(path); + _recodeDuration = 0; + _startTimer(); + isRecoding = !isRecoding; + notifyListeners(); + } + Future _startTimer() async { _timer?.cancel(); _timer = Timer.periodic(const Duration(seconds: 1), (Timer t) async {