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 == ARROW_UP) {
      if (index > 0) {
        index--;
      }
    } else if (input == ARROW_DOWN) {
      if (index < items!.length - 1) {
        index++;
      }
    }
    _renderList(index);
  }
  _resetStdin();
  return items![index];
}