posShortcutConflict function

({String action, String heldBy, String key})? posShortcutConflict(
  1. Map<String, Object?> shortcuts
)

Die erste Doppelbelegung einer Tastenkarte oder null. Geprüft wird die ganze Karte, so wie der Server sie nach dem Speichern hält. Zwilling von posShortcutConflict.

Implementation

({String action, String key, String heldBy})? posShortcutConflict(Map<String, Object?> shortcuts) {
  final belegt = <String, String>{};
  for (final aktion in shortcuts.keys) {
    final tasten = shortcuts[aktion];
    if (tasten is! List) continue;
    for (final t in tasten) {
      if (t is! String) continue;
      final vorher = belegt[t];
      if (vorher != null && vorher != aktion && !_darfTeilen(vorher, aktion)) {
        return (action: aktion, key: t, heldBy: vorher);
      }
      belegt[t] = aktion;
    }
  }
  return null;
}