ComponentState class

An experimental change detection mixin/base class for specific use cases.

Instead of setting changeDetection: ChangeDetectionStrategy.*, you may extend or mixin ComponentState. By doing so, the setState instance method becomes the only mechanism in which the component will be checked by change detection.

Unlike ChangeDetectionStrategy.OnPush:

  • You may override @Input-annotated setters and call setState.
  • Some lifecycle events (such as AfterChanges, OnChanges) are rejected.

WARNING: It is currently undefined behavior to mix a component that is using ComponentState with children that use another change detection type, and as such it is highly suggested to only use ComponentState on components that represent a low-level repeated component, such as a cell in a table, and in other cases to use ChangeDetectionStrategy.OnPush.

It is not valid to use implements with this class.

  • @experimental




hashCode → int
The hash code for this object. [...]
read-only, inherited
runtimeType → Type
A representation of the runtime type of the object.
read-only, inherited


deliverStateChanges() → void
Semantically identical to calling setState((){}). [...]
@Deprecated('Do not override this method. It will be removed'), @protected
setState(void scheduleChangeDetectionAfter()) → void
Invokes the provided function and schedules change detection to occur. [...]
noSuchMethod(Invocation invocation) → dynamic
Invoked when a non-existent method or property is accessed. [...]
toString() → String
Returns a string representation of this object.


operator ==(dynamic other) → bool
The equality operator. [...]