removeTag method

void removeTag(
  1. int index
)

Removes a tag from the tag list at the specified index.

Validates the index bounds before removal. If successful, notifies listeners and triggers the appropriate callbacks defined in the TagField.

Parameters:

  • index: The index of the tag to remove from the list

Returns: Nothing. If the index is invalid, the method returns early without changes.

Example:

notifier.removeTag(0); // Removes the first tag

Implementation

void removeTag(int index) {
  if (index < 0 || index >= _tags.length) return;

  final removedTag = _tags[index];
  _tags.removeAt(index);
  notifyListeners();

  widget.onTagRemoved?.call(removedTag);
  widget.onTagsChanged?.call(_tags);
}