ChipEditingController<T> class
A text editing controller that supports inline chip widgets.
Extends TextEditingController to manage text with embedded chip objects represented by special Unicode codepoints from the Private Use Area (U+E000-U+F8FF). Each chip is mapped to a unique codepoint allowing up to 6400 chips per controller.
Use this when you need to display removable tags or tokens within a text field, such as email recipients, keywords, or selected items.
Example:
final controller = ChipEditingController<String>(
initialChips: ['tag1', 'tag2'],
);
- Inheritance
-
- Object
- ChangeNotifier
- ValueNotifier<
TextEditingValue> - TextEditingController
- ChipEditingController
- Available extensions
Constructors
-
ChipEditingController({String? text, List<
T> ? initialChips}) -
Factory constructor creating a chip editing controller.
factory
Properties
-
chips
↔ List<
T> -
Returns an unmodifiable list of all chips in the controller.
getter/setter pair
- currentWord → String?
-
Available on TextEditingController, provided by the TextEditingControllerExtension extension
Gets the word at the current cursor position.no setter - hashCode → int
-
The hash code for this object.
no setterinherited
- hasListeners → bool
-
Whether any listeners are currently registered.
no setterinherited
- plainText → String
-
Returns the plain text without chip characters.
no setter
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- selection ↔ TextSelection
-
The currently selected range within text.
getter/setter pairinherited
- text ↔ String
-
The current string the user is editing.
getter/setter pairinherited-getteroverride-setter
- textAtCursor → String
-
Returns the text at the current cursor position.
no setter
- value ↔ TextEditingValue
-
The current value stored in this notifier.
getter/setter pairinherited-getteroverride-setter
Methods
-
addListener(
VoidCallback listener) → void -
Register a closure to be called when the object changes.
inherited
-
appendChip(
T chip) → void - Appends a chip at the end of the chip sequence.
-
appendChipAtCursor(
T chip) → void - Appends a chip at the current cursor position.
-
buildTextSpan(
{required BuildContext context, TextStyle? style, required bool withComposing}) → TextSpan -
Builds TextSpan from current editing value.
override
-
clear(
) → void -
Set the value to empty.
inherited
-
clearComposing(
) → void -
Set the composing region to an empty range.
inherited
-
clearTextAtCursor(
) → void - Clears the text at the current cursor position.
-
dispose(
) → void -
Discards any resources used by the object.
inherited
-
getSelectionSpans(
TextSelection selection) → List< InlineSpan> -
Returns the spans covered by
selection, with chips as ChipSpans. -
insertChip(
T chip) → void - Inserts a chip at a specific position in the text.
-
insertChipAtCursor(
T? chipConverter(String chipText)) → void - Inserts a chip at the cursor position by converting the text at cursor.
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
notifyListeners(
) → void -
Call all the registered listeners.
inherited
-
removeAllChips(
) → void - Removes all chips from the controller, leaving only plain text.
-
removeChip(
T chip) → void - Removes the specified chip from the controller.
-
removeListener(
VoidCallback listener) → void -
Remove a previously registered closure from the list of closures that are
notified when the object changes.
inherited
-
replaceSelectionWithSpans(
List< InlineSpan> spans) → void -
Replaces the current selection with the given
spans. -
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited