requestPermission static method

Future<bool> requestPermission(
  1. List<Permission> permissions, {
  2. String? deniedTip,
})

Implementation

static Future<bool> requestPermission(List<Permission> permissions,
    {String? deniedTip}) async {
  final status = await permissions.request();
  Alog.e(
      tag: 'Permission',
      moduleName: 'requestPermission',
      content: 'Permission status $status');

  bool isAllGranted = true;
  bool showTip = false;
  status.forEach((key, value) {
    if (value.isDenied || value.isPermanentlyDenied) {
      isAllGranted = false;
    }
    if (value.isPermanentlyDenied) {
      showTip = true;
    }
  });
  if (showTip) {
    Fluttertoast.showToast(
        msg: deniedTip?.isNotEmpty == true
            ? deniedTip!
            : S.of().permissionRequestTip);
  }
  return isAllGranted;
}