promptEditSectionNumber function

int promptEditSectionNumber(
  1. WizardIo io,
  2. int sectionCount
)

Prompts for which section (1-based, excluding the summary itself) to jump to and edit; returns the 0-based section index.

Implementation

int promptEditSectionNumber(WizardIo io, int sectionCount) {
  while (true) {
    final input = io
        .prompt('Section number to edit [1-$sectionCount]: ')
        .trim();
    final n = int.tryParse(input);
    if (n != null && n >= 1 && n <= sectionCount) return n - 1;
    io.writeLine('Invalid section number.');
  }
}