askTheme static method
Theme/option selector with an appended "Back" item that throws BackNavigation when chosen.
Implementation
static Future<int> askTheme(
String prompt,
List<String> themes,
List<String> descriptions, {
int initialIndex = 0,
String? fromStep,
}) async {
final List<String> options = <String>[
for (int i = 0; i < themes.length; i++)
if (i < descriptions.length)
'${themes[i]} - ${descriptions[i]}'
else
themes[i],
backOptionLabel,
];
final int chosen = await UserPrompt.showMenu(
prompt,
options,
defaultIndex: initialIndex,
);
if (chosen == options.length - 1) {
throw BackNavigation(fromStep: fromStep);
}
return chosen;
}