findSubsystemByIds<TSubsystem extends Subsystem> static method

TSubsystem? findSubsystemByIds<TSubsystem extends Subsystem>(
  1. String typeId,
  2. String classId
)

Finds a subsystem singleton by its type and class IDs.

Returns null if no matching instance is found.

Implementation

static TSubsystem? findSubsystemByIds<TSubsystem extends Subsystem>(
  String typeId,
  String classId,
) {
  final registry = findRegistryForTypeId(typeId);
  if (registry != null) {
    final singleton = registry.findByClassId(classId);
    if (singleton != null && singleton is! TSubsystem) {
      throw TypeError();
    }
    return singleton as TSubsystem?;
  }
  return null;
}