Menu<T> constructor

Menu<T>(
  1. Iterable<T> options, {
  2. bool? useAnsi,
  3. Stdin? stdin,
  4. Stdout? stdout,
  5. List<String> modifierKeys = const [],
})

Defines a menu with a list of options.

For best results, try to provide only as many options as can fit on a single terminal screen (i.e. less than ~40). Otherwise, the ANSI rewriting stops working well.

The terminal's ANSI capabilities are autodetected, but you can set useAnsi to override this.

Provide own stdin and stdout for testing or for custom environments. These default to the system STD IN and STD OUT.

Implementation

Menu(
  Iterable<T> options, {
  bool? useAnsi,
  io.Stdin? stdin,
  io.Stdout? stdout,
  List<String> modifierKeys = const [],
})  : _options = List.unmodifiable(options),
      _useAnsi = useAnsi ?? Ansi.terminalSupportsAnsi,
      _stdin = stdin ?? io.stdin,
      _stdout = stdout ?? io.stdout,
      _modifierKeys = modifierKeys {
  _ensureModifierKeysValid();
}