fluent2FirstFocus function

int fluent2FirstFocus(
  1. List<bool> enabled,
  2. int chosen
)

The option Fluent2ListKeys puts the focus on as a list opens: the chosen one (chosen, an index) when it is in use, else the first in use.

Implementation

int fluent2FirstFocus(List<bool> enabled, int chosen) {
  if (chosen >= 0 && chosen < enabled.length && enabled[chosen]) return chosen;
  final first = enabled.indexOf(true);
  return first < 0 ? 0 : first;
}