removeAllChips method

void removeAllChips()

Removes all chips from the controller, leaving only plain text.

Implementation

void removeAllChips() {
  StringBuffer buffer = StringBuffer();
  String text = value.text;
  for (int i = 0; i < text.length; i++) {
    int codeUnit = text.codeUnitAt(i);
    if (codeUnit < _chipStart || codeUnit > _chipEnd) {
      buffer.writeCharCode(codeUnit);
    }
  }
  super.value = value.copyWith(
    text: buffer.toString(),
    selection: TextSelection.collapsed(offset: buffer.length),
  );
  _chipMap.clear();
}