permissionCheck method
Future<PermissionState>
permissionCheck({
- PermissionRequestOption requestOption = const PermissionRequestOption(),
Request the current PermissionState of required permissions. 请求所需权限的 PermissionState。
Throws a StateError when the state is not PermissionState.authorized or PermissionState.limited, which means the picker can not perform further actions. 当权限状态不是 PermissionState.authorized 或 PermissionState.limited 时, 将抛出 StateError,此时选择器无法执行其他操作。
See also:
- PermissionState which defined all states of required permissions.
Implementation
Future<PermissionState> permissionCheck({
PermissionRequestOption requestOption = const PermissionRequestOption(),
}) async {
final PermissionState ps = await PhotoManager.requestPermissionExtend(
requestOption: requestOption,
);
if (ps != PermissionState.authorized && ps != PermissionState.limited) {
throw StateError('Permission state error with $ps.');
}
return ps;
}