use method

Future<PermissionStatus> use({
  1. dynamic onAccept(
    1. PermissionStatus
    )?,
  2. dynamic onDenied(
    1. PermissionStatus
    )?,
  3. bool showSettingDialog = true,
  4. String? permissionTitle,
})

Implementation

Future<PermissionStatus> use({
  Function(PermissionStatus)? onAccept,
  Function(PermissionStatus)? onDenied,
  bool showSettingDialog = true,
  String? permissionTitle,
}) async {
  Permission permission = await _handleMediaPermission();
  final PermissionStatus status = await permission.request();
  if (status.isGranted || status.isLimited) {
    onAccept?.call(status);
  } else if (onDenied != null) {
    onDenied.call(status);
  } else if (status.isPermanentlyDenied && showSettingDialog) {
    String title = permissionTitle ?? permission._handleSettingTitle();
    PermissionContext.showSettingDialog(text: title);
  }
  return status;
}