ComponentState class

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

WARNING: This class is soft deprecated. It's now just an alias for ChangeDetectionStrategy.OnPush, which should be preferred when writing new components over extending this class.

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.

It is not valid to use implements with this class.

Annotations

Constructors

ComponentState()

Properties

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

Methods

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

Operators

operator ==(Object other) bool
The equality operator. [...]
inherited