choose method

String choose()

Similar to ask this actually triggers the dialog and returns the chosen item = option.

Implementation

String choose() {
  int? input;
  var index = 0;

  _renderList(0, initial: true);

  while ((input = _userInput()) != enter) {
    if (input! < 0) {
      _resetStdin();
      return ':${-input}';
    }
    if (input == arrowUp) {
      if (index > 0) {
        index--;
      }
    } else if (input == arrowDown) {
      if (index < items!.length - 1) {
        index++;
      }
    }
    _renderList(index);
  }
  _resetStdin();
  return items![index];
}