resolveLabelOrPrefix function
Resolves typed against the account's keys — an exact label match wins
outright (the backend enforces at most one active key per label, so an
exact match can never itself be ambiguous), otherwise falls back to
KeyMatcher's prefix matching. keys list's prefix column stays a
valid handle to paste. Pure, so this ordering is pinned by a test
rather than left incidental.
Implementation
List<Map<String, dynamic>> resolveLabelOrPrefix(
List<Map<String, dynamic>> keys,
String typed,
) {
final labelMatches = keys.where((key) => key['name'] == typed).toList();
if (labelMatches.isNotEmpty) return labelMatches;
return KeyMatcher.resolve(keys, typed);
}