showMenu static method

Future<int> showMenu(
  1. String title,
  2. List<String> options, {
  3. int? defaultIndex,
  4. String? fromStep,
})

Plain menu with a Back option appended.

Implementation

static Future<int> showMenu(
  String title,
  List<String> options, {
  int? defaultIndex,
  String? fromStep,
}) async {
  final List<String> withBack = <String>[
    ...options,
    backOptionLabel,
  ];
  final int chosen = await UserPrompt.showMenu(
    title,
    withBack,
    defaultIndex: defaultIndex,
  );
  if (chosen == withBack.length - 1) {
    throw BackNavigation(fromStep: fromStep);
  }
  return chosen;
}