ChipInputController<T> class
Reactive controller for managing chip input state with convenient methods.
Extends ValueNotifier to provide state management for chip input widgets containing lists of typed objects. Supports adding, removing, and clearing chips programmatically while notifying listeners of changes.
The controller maintains a list of items of type T
and provides methods
for common list operations in chip input contexts.
Example:
final controller = ChipInputController<String>(['initial', 'chips']);
// React to changes
controller.addListener(() {
print('Chips: ${controller.value}');
});
// Programmatic control
controller.add('new chip');
controller.removeAt(0);
- Inheritance
-
- Object
- ChangeNotifier
- ValueNotifier<
List< T> > - ChipInputController
- Mixed-in types
Constructors
-
ChipInputController.new([List<
T> value = const []]) - Creates a ChipInputController with an optional initial list of chips.
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- hasListeners → bool
-
Whether any listeners are currently registered.
no setterinherited
- isEmpty → bool
-
Returns true if the chip input is empty.
no setter
- isNotEmpty → bool
-
Returns true if the chip input contains at least one chip.
no setter
- length → int
-
Returns the number of chips currently in the input.
no setter
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
-
value
↔ List<
T> -
The current value stored in this notifier.
getter/setter pairinherited
Methods
-
add(
T chip) → void - Adds a new chip to the end of the current list.
-
addListener(
VoidCallback listener) → void -
Register a closure to be called when the object changes.
inherited
-
clear(
) → void - Removes all chips from the input.
-
contains(
T chip) → bool - Returns true if the chip list contains the specified chip.
-
dispose(
) → void -
Discards any resources used by the object. After this is called, the
object is not in a usable state and should be discarded (calls to
addListener will throw after the object is disposed).
inherited
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
notifyListeners(
) → void -
Call all the registered listeners.
inherited
-
remove(
T chip) → void - Removes all chips matching the provided chip.
-
removeAt(
int index) → void - Removes the chip at the specified index.
-
removeListener(
VoidCallback listener) → void -
Remove a previously registered closure from the list of closures that are
notified when the object changes.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited