singleOrNull method
(Entity, A, B, C)?
singleOrNull(
)
Implementation
(Entity, A, B, C)? singleOrNull() {
final driver = Query.chooseDriver(_driverCandidates);
final driverIsA = identical(driver, _a);
final driverIsB = identical(driver, _b);
final driverIsC = identical(driver, _c);
_world.beginQuery(this);
try {
(Entity, A, B, C)? match;
for (var i = 0; i < driver.length; i++) {
final entityIndex = driver.entityIndexAt(i);
final aDense = driverIsA ? i : _a.denseIndexOf(entityIndex);
if (aDense < 0) continue;
final bDense = driverIsB ? i : _b.denseIndexOf(entityIndex);
if (bDense < 0) continue;
final cDense = driverIsC ? i : _c.denseIndexOf(entityIndex);
if (cDense < 0) continue;
if (!Query.passesFilters(entityIndex, _withStores, _withoutStores)) {
continue;
}
if (match != null) {
throw StateError(
'Query3<$A, $B, $C>.single: expected exactly one matching entity, '
'found more than one.',
);
}
match = (
_world.entities.resolve(entityIndex),
_a.valueAt(aDense),
_b.valueAt(bDense),
_c.valueAt(cDense),
);
}
return match;
} finally {
_world.endQuery();
}
}