mostUsedKey method

String mostUsedKey(
  1. Map<String, Set<String>> secrets
)

Implementation

String mostUsedKey(Map<String, Set<String>> secrets) {
  final usage = <String, int>{};
  for (final keys in secrets.values) {
    for (final key in keys) {
      usage.update(key, (i) => i + 1, ifAbsent: () => 1);
    }
  }
  final entriesList = usage.entries.toList();
  entriesList.sort((a, b) => a.value.compareTo(b.value));
  return entriesList.first.key;
}