shouldRebuild method
Whether what the controller holds now is worth a frame, given what read last recorded.
- Nothing read yet: yes.
- The observed state equal to the one built: no, before
buildWhenis even asked. The first build reads the result straight after the subscribe started the fetch, and the observer's notification about that very fetch arrives after the frame — a rebuild with nothing new in it. Results carry value equality, so "nothing new" is==. - What is beside the value moved, with the value or without it: yes,
before
buildWhenis asked. It cannot judge what it is not shown, and a "no" would leave the reader showing the stale half — "Load more" with no next page. Without abeside, the same holds when the observed state moved and the value is equal. - Otherwise, as
buildWhensays; with none, yes.
Implementation
bool shouldRebuild(BuildWhen<T>? buildWhen) {
if (!_recorded) {
return true;
}
if (_observedState() == _builtState) {
return false;
}
final beside = _beside;
if (beside != null && beside() != _builtBeside) {
return true;
}
final current = _value();
if (current == _built) {
return true;
}
return buildWhen == null || buildWhen(_built, current);
}