didChange method
- When
from
and to
are provided - returns true
when state did change from
to to
.
- When only
from
is provided - returns true
when state did change from from
.
- When only
to
is provided - returns true
when state did change to to
.
- When
from
and to
equals null
- returns true
for any state change.
Implementation
bool didChange({IndicatorState? from, IndicatorState? to}) {
final stateChanged = currentState != newState;
if (to == null && from != null) return currentState == from && stateChanged;
if (to != null && from == null) return newState == to && stateChanged;
if (to == null && from == null) return stateChanged;
return currentState == from && newState == to;
}