numRepetitions method

int numRepetitions(
  1. FormIndex index
)

The number of instances of the repeat at index.

Implementation

int numRepetitions(FormIndex index) {
  if (!index.isInForm) throw StateError('not an in-form index');
  final last = elementAt(index);
  if (last is! GroupDef || !last.isRepeat) {
    throw StateError('current element not a repeat');
  }
  final template = mainInstance.getTemplate(index.reference!)!;
  final parentPath = template.parent!.ref.genericize();
  final parentNode = mainInstance.resolveReference(
    parentPath.contextualize(index.reference!)!,
  )!;
  return parentNode.childMultiplicity(template.name!);
}