From 1f69ee262db5dc3919c6bec374882c4ae9ca8521 Mon Sep 17 00:00:00 2001 From: "Aamir.Muhammad" Date: Tue, 3 Jan 2023 16:33:27 +0300 Subject: [PATCH 1/2] Permission Issue --- lib/provider/chat_provider_model.dart | 84 +++++++++++++++------------ 1 file changed, 48 insertions(+), 36 deletions(-) diff --git a/lib/provider/chat_provider_model.dart b/lib/provider/chat_provider_model.dart index fb61891..23feefc 100644 --- a/lib/provider/chat_provider_model.dart +++ b/lib/provider/chat_provider_model.dart @@ -1201,47 +1201,59 @@ class ChatProviderModel with ChangeNotifier, DiagnosticableTreeMixin { } void startRecoding(BuildContext context) async { - // if (await Permission.microphone.request().isGranted) { - // sRecoding(); - // } else { - // Utils.showToast("Permission Issue"); - // openAppSettings(); - // } - await Permission.microphone.request().then((PermissionStatus status) { - if (status.isPermanentlyDenied) { - Utils.confirmDialog( - context, - "The app needs microphone access to be able to record audio.", - onTap: () { - openAppSettings(); - }, - ); - } else if (status.isDenied) { - Utils.confirmDialog( - context, - "The app needs microphone access to be able to record audio.", - onTap: () { - openAppSettings(); - }, - ); - } else if (status.isGranted) { - sRecoding(); + await Permission.microphone.request().then((PermissionStatus status) async { + if (Platform.isIOS) { + if (status.isPermanentlyDenied) { + Utils.confirmDialog( + context, + "The app needs microphone access to be able to record audio.", + onTap: () { + openAppSettings().then((bool value) { + if (status.isGranted) { + Navigator.of(context).pop(); + } + }); + }, + ); + } else if (status.isDenied) { + Utils.confirmDialog( + context, + "The app needs microphone access to be able to record audio.", + onTap: () { + openAppSettings().then((bool value) { + if (status.isGranted) { + Navigator.of(context).pop(); + } + }); + }, + ); + } else if (status.isGranted) { + sRecoding(); + } else { + startRecoding(context); + } } else { - startRecoding(context); + if (status.isPermanentlyDenied) { + Utils.confirmDialog( + context, + "The app needs microphone access to be able to record audio.", + onTap: () { + openAppSettings().then((bool value) { + if (status.isGranted) { + Navigator.of(context).pop(); + } + }); + }, + ); + } else if (status.isGranted) { + sRecoding(); + } else { + startRecoding(context); + } } }); } - // else { - // isVoiceMsg = true; - // recorderController.reset(); - // await recorderController.record(path); - // _recodeDuration = 0; - // _startTimer(); - // isRecoding = !isRecoding; - // notifyListeners(); - // } - void sRecoding() async { isVoiceMsg = true; recorderController.reset(); From b152f8a6d6c97eadf3615fb2bced096cb72ca360 Mon Sep 17 00:00:00 2001 From: "Aamir.Muhammad" Date: Tue, 3 Jan 2023 17:14:49 +0300 Subject: [PATCH 2/2] Permission Issue --- lib/provider/chat_provider_model.dart | 70 +++++++++------------------ 1 file changed, 22 insertions(+), 48 deletions(-) diff --git a/lib/provider/chat_provider_model.dart b/lib/provider/chat_provider_model.dart index 23feefc..460a338 100644 --- a/lib/provider/chat_provider_model.dart +++ b/lib/provider/chat_provider_model.dart @@ -1201,55 +1201,29 @@ class ChatProviderModel with ChangeNotifier, DiagnosticableTreeMixin { } void startRecoding(BuildContext context) async { - await Permission.microphone.request().then((PermissionStatus status) async { - if (Platform.isIOS) { - if (status.isPermanentlyDenied) { - Utils.confirmDialog( - context, - "The app needs microphone access to be able to record audio.", - onTap: () { - openAppSettings().then((bool value) { - if (status.isGranted) { - Navigator.of(context).pop(); - } - }); - }, - ); - } else if (status.isDenied) { - Utils.confirmDialog( - context, - "The app needs microphone access to be able to record audio.", - onTap: () { - openAppSettings().then((bool value) { - if (status.isGranted) { - Navigator.of(context).pop(); - } - }); - }, - ); - } else if (status.isGranted) { - sRecoding(); - } else { - startRecoding(context); - } + await Permission.microphone.request().then((PermissionStatus status) { + if (status.isPermanentlyDenied) { + Utils.confirmDialog( + context, + "The app needs microphone access to be able to record audio.", + onTap: () { + Navigator.of(context).pop(); + openAppSettings(); + }, + ); + } else if (status.isDenied) { + Utils.confirmDialog( + context, + "The app needs microphone access to be able to record audio.", + onTap: () { + Navigator.of(context).pop(); + openAppSettings(); + }, + ); + } else if (status.isGranted) { + sRecoding(); } else { - if (status.isPermanentlyDenied) { - Utils.confirmDialog( - context, - "The app needs microphone access to be able to record audio.", - onTap: () { - openAppSettings().then((bool value) { - if (status.isGranted) { - Navigator.of(context).pop(); - } - }); - }, - ); - } else if (status.isGranted) { - sRecoding(); - } else { - startRecoding(context); - } + startRecoding(context); } }); }