import 'package:logging/logging.dart'; import 'package:nc_photos/stream_extension.dart'; import 'package:np_platform_permission/np_platform_permission.dart'; Future> requestPermissionsForResult( List permissions) => _doRequest(() => Permission.request(permissions)); Future> requestReadExternalStorageForResult() => _doRequest(() => Permission.requestReadExternalStorage()); Future> requestPostNotificationsForResult() => _doRequest(() => Permission.requestPostNotifications()); Future> _doRequest(Future Function() op) async { Map? result; final resultFuture = Permission.stream .whereType() .first .then((ev) => result = ev.grantResults); await op(); await resultFuture; _log.info("[_doRequest] Result: $result"); return result!; } final _log = Logger("mobile.android.permission_util");