Browse Source

[new]增加权限状态检查

zk 1 year ago
parent
commit
1cd39cd348
1 changed files with 7 additions and 4 deletions
  1. 7 4
      lib/module/record/record_handler.dart

+ 7 - 4
lib/module/record/record_handler.dart

@@ -211,10 +211,13 @@ class RecordHandler {
   }
 
   Future<void> startOrContinueRecord() async {
-    var status = await Permission.microphone.request();
-    if (status != PermissionStatus.granted) {
-      _onRecordPermissionDenied();
-      return;
+    var status = await Permission.microphone.status;
+    if (!status.isGranted) {
+      var result = await Permission.microphone.request();
+      if (!result.isGranted) {
+        _onRecordPermissionDenied();
+        return;
+      }
     }
 
     await _requestForegroundTaskPermission().catchError((error) {