getAndroidPermission function
Gets the Android permission string for a given key.
Throws an ArgumentError with helpful suggestions if the key is not found.
Example
try {
final perm = getAndroidPermission('camera');
print(perm); // android.permission.CAMERA
} on ArgumentError catch (e) {
print('Error: ${e.message}');
}
Implementation
String getAndroidPermission(String key) {
final permission = androidPermissions[key.toLowerCase()];
if (permission == null) {
final suggestions = androidPermissions.keys.take(5).join(', ');
throw ArgumentError(
'Permission "$key" not found. Try one of: $suggestions, ...\n'
'Run with --list to see all available permissions.',
);
}
return permission;
}