debugAssertConsistent method
void
debugAssertConsistent()
Verifies _activeSlideNids mirrors _slideByNid exactly. Throws
StateError on inconsistency. Wrapped in assert at call sites so
release builds skip it.
Implementation
void debugAssertConsistent() {
int slideCount = 0;
int xCount = 0;
for (int nid = 0; nid < _slideByNid.length; nid++) {
final entry = _slideByNid[nid];
if (entry != null) {
if (_nids.keyOf(nid) == null) {
throw StateError("_slideByNid[$nid] non-null for freed slot");
}
if (!_activeSlideNids.contains(nid)) {
throw StateError(
"_slideByNid[$nid] non-null but missing from _activeSlideNids",
);
}
slideCount++;
if (entry.startDeltaX != 0.0) xCount++;
}
}
if (_activeSlideNids.length != slideCount) {
throw StateError(
"_activeSlideNids has ${_activeSlideNids.length} entries, "
"but only $slideCount nids carry a slide slot",
);
}
if (_xActiveCount != xCount) {
throw StateError(
"_xActiveCount=$_xActiveCount but $xCount entries have non-zero "
"startDeltaX",
);
}
}