nc-photos/app/lib/mobile/android/permission_util.dart

19 lines
625 B
Dart
Raw Normal View History

import 'package:logging/logging.dart';
import 'package:nc_photos/stream_extension.dart';
2023-08-31 20:34:48 +02:00
import 'package:np_platform_permission/np_platform_permission.dart';
Future<Map<String, int>> requestPermissionsForResult(
List<String> permissions) async {
Map<String, int>? result;
final resultFuture = Permission.stream
.whereType<PermissionRequestResult>()
.first
.then((ev) => result = ev.grantResults);
await Permission.request(permissions);
await resultFuture;
_log.info("[requestPermissionsForResult] Result: $result");
return result!;
}
final _log = Logger("mobile.android.permission_util");