descendIntoRepeat method

FormIndex descendIntoRepeat(
  1. FormIndex index,
  2. int repIndex
)

The index of instance repIndex of the repeat at index; -1 means the instance about to be created.

Implementation

FormIndex descendIntoRepeat(FormIndex index, int repIndex) {
  final count = numRepetitions(index);
  final indexes = <int>[];
  final multiplicities = <int>[];
  final elements = <FormElement>[];
  collapseIndex(index, indexes, multiplicities, elements);
  if (repIndex == -1) {
    repIndex = count;
  } else if (repIndex < 0 || repIndex >= count) {
    throw StateError('selection exceeds current number of repetitions');
  }
  multiplicities[multiplicities.length - 1] = repIndex;
  return buildIndex(indexes, multiplicities, elements)!;
}