Flutter 请求相机权限不起作用

问题描述 投票:0回答:1

运行该函数时没有收到权限提示:

 getPermissionStatus() async {
    await Permission.camera.request();
    var status = await Permission.camera.status;
    print(status);
    if (status.isGranted) {
      log('Camera Permission: GRANTED');
      setState(() {
        isCameraPermissionGranted = true;
      });
      // Set and initialize the new camera
      onNewCameraSelected(cameras[0]);
      refreshAlreadyCapturedImages();
    } else if (status.isPermanentlyDenied) {
      // The user opted to never again see the permission request dialog for this
      // app. The only way to change the permission's status now is to let the
      // user manually enable it in the system settings.
      openAppSettings();
    } else {
      log('Camera Permission: DENIED');
    }
  }

日志始终...PermissionStatus.denied

flutter permissions camera
1个回答
0
投票
Make sure you add camera permission in AndroidManifest
Like:-<uses-permission android:name="android.permission.CAMERA" />
© www.soinside.com 2019 - 2024. All rights reserved.