insert method

void insert(
  1. int index,
  2. AbstractControl<T> control, {
  3. bool updateParent = true,
  4. bool emitEvent = true,
})

Insert a control at the given index position.

The argument index is the position starting from 0 where to insert the control.

The argument control is the item to insert.

When updateParent is true or not supplied (the default) each change affects this control and its parent, otherwise only affects to this control.

When emitEvent is true or not supplied (the default), both the statusChanges and valueChanges emit events with the latest status and value when the control is reset. When false, no events are emitted.

Implementation

void insert(
  int index,
  AbstractControl<T> control, {
  bool updateParent = true,
  bool emitEvent = true,
}) {
  _controls.insert(index, control);
  control.parent = this;

  updateValueAndValidity(
    emitEvent: emitEvent,
    updateParent: updateParent,
  );

  if (emitEvent) {
    emitsCollectionChanged(_controls);
  }
}