getPermissionKeys method

List<String> getPermissionKeys()

Gets the list of permission keys currently in Info.plist.

Implementation

List<String> getPermissionKeys() {
  final plistFile = File(_infoPlistPath);

  if (!plistFile.existsSync()) {
    return [];
  }

  try {
    final content = plistFile.readAsStringSync();

    final keyPattern = RegExp(r'<key>(NS\w+UsageDescription)</key>');
    final matches = keyPattern.allMatches(content);

    return matches.map((m) => m.group(1)!).toList();
  } catch (_) {
    return [];
  }
}