appendChipAtCursor method

void appendChipAtCursor(
  1. T chip
)

Appends a chip at the current cursor position.

Implementation

void appendChipAtCursor(T chip) {
  // append chip at the cursor position
  final boundaries = _findChipTextBoundaries(selection.baseOffset);
  String text = value.text;
  int chipIndex = _nextAvailableChipIndex;
  String newText = text.replaceRange(boundaries.end, boundaries.end,
      String.fromCharCode(_chipStart + chipIndex));
  super.value = value.copyWith(
    text: newText,
    selection: TextSelection.collapsed(offset: boundaries.end + 1),
  );
  _chipMap[chipIndex] = chip;
}