generateChoice function

String generateChoice(
  1. String name, [
  2. String? description,
  3. bool isDefault = false
])

Generate a formatted choice line

Implementation

String generateChoice(
  String name, [
  String? description,
  bool isDefault = false,
]) {
  final sb = StringBuffer();
  final star = (isDefault ? ' * ' : '');
  String choice = (name + star);
  if (description != null) {
    choice = choice.padRight(20);
  }
  sb.write(choice);
  if (description != null) {
    sb.write(description.truncateChoiceDescription(choice.length));
  }
  String line = sb.toString();
  line = line;
  return line;
}