deleteZTChip method
to Handle chip deletion while tapping on the close button
Implementation
void deleteZTChip(String deletedValue, TextEditingController controller) {
if (widget.enabled) {
textEditingController.convertedText = textEditingController.convertedText
.replaceAll("$deletedValue", "")
.trim(); //to remove the extra spacing we give for the last chip
///trim() applied to remove the extra spacing we give for the last chip
textEditingController.value = TextEditingValue(
text: controller.text.replaceAll("$deletedValue", ""),
selection: TextSelection(
baseOffset: ((textEditingController.text.length - 1) - deletedValue.length),
extentOffset: ((textEditingController.text.length - 1) - deletedValue.length)));
}
}