captionHierarchy method

List<FormEntryCaption> captionHierarchy([
  1. FormIndex? index
])

Captions of the groups and the question along index (by default the current index), outermost first.

Implementation

List<FormEntryCaption> captionHierarchy([FormIndex? index]) {
  index ??= _currentFormIndex;
  final captions = <FormEntryCaption>[];
  FormIndex? remaining = index;
  while (remaining != null) {
    remaining = remaining.nextLevel;
    final localIndex = index.diff(remaining)!;
    final element = form.elementAt(localIndex);
    if (element is GroupDef) {
      captions.add(FormEntryCaption(form, localIndex));
    } else if (element is QuestionDef) {
      captions.add(FormEntryPrompt(form, localIndex));
    }
  }
  return captions;
}