performCheckForCyclicDependencies method
Checks if object with type id is currently building and throws exception if so
Implementation
void performCheckForCyclicDependencies(String typeId, int? index) {
if (!checkForCyclicDependencies) {
return;
}
final currentlyBuildingInstances = buildingInstances[typeId];
if (currentlyBuildingInstances == null) {
buildingInstances[typeId] = [index ?? 0];
return;
}
if (currentlyBuildingInstances.contains(index ?? 0)) {
throw IllegalArgumentException(
message: 'Detected cyclic dependency on $typeId',
);
}
// this can happen only in testing,
// cause countable instances are connected sequentially
// coverage:ignore-start
currentlyBuildingInstances.add(index ?? 0);
// coverage:ignore-end
}