removeRepeat method

void removeRepeat(
  1. String xPath
)

Removes the repeat instance at xPath.

Implementation

void removeRepeat(String xPath) {
  final reference = expandSingle(getRef(xPath));
  final group = formDef.mainInstance.resolveReference(reference)!;
  FormIndex? childIndex;
  for (final child in group.children) {
    childIndex = _indexOf(child.ref);
    if (childIndex != null) break;
  }
  if (childIndex == null) {
    throw StateError(
      "Can't find an index inside the repeat group you want to remove. "
      'Please add some field and a form control.',
    );
  }
  formDef.deleteRepeat(childIndex);
}