pickNativeMatch<T> function

NativeMatchPick<T> pickNativeMatch<T>(
  1. List<T> matches, {
  2. required int? index,
})

Picks the match to tap: the one at index (0-based, screen order, like fdb tap --index), or the only match when index is null.

Implementation

NativeMatchPick<T> pickNativeMatch<T>(List<T> matches, {required int? index}) {
  if (matches.isEmpty) return NativeMatchNone<T>();
  if (index != null) {
    return index >= 0 && index < matches.length ? NativeMatchPicked<T>(matches[index]) : NativeMatchNone<T>();
  }
  if (matches.length == 1) return NativeMatchPicked<T>(matches.single);
  return NativeMatchAmbiguous<T>(matches);
}