event method

FormEntryEvent event([
  1. FormIndex? index
])

What is at index (by default the current index).

Implementation

FormEntryEvent event([FormIndex? index]) {
  index ??= _currentFormIndex;
  if (index.isBeginningOfFormIndex) return FormEntryEvent.beginningOfForm;
  if (index.isEndOfFormIndex) return FormEntryEvent.endOfForm;
  final element = form.elementAt(index);
  if (element is GroupDef) {
    if (!element.isRepeat) return FormEntryEvent.group;
    if (repeatStructure != RepeatStructure.nonLinear &&
        form.mainInstance.resolveReference(form.childInstanceRef(index)!) ==
            null) {
      return FormEntryEvent.promptNewRepeat;
    }
    if (repeatStructure == RepeatStructure.nonLinear &&
        index.elementMultiplicity == TreeReference.indexRepeatJuncture) {
      return FormEntryEvent.repeatJuncture;
    }
    return FormEntryEvent.repeat;
  }
  return FormEntryEvent.question;
}