addChip method

void addChip(
  1. String value
)

adds the chip to the list, clear the text field and calls widget.onChanged

Implementation

void addChip(String value) {
  if (value.isEmpty || _hasReachedMaxChips) {
    textCtrl.clear();
    widget.onMaxChipsReached?.call();
    return;
  }
  setState(() {
    controller.addChip(value.trim());
  });
  textCtrl.clear();
  widget.onChanged(controller.chips);
}