resolveCatalog function

A2uiCatalog resolveCatalog(
  1. Registry registry,
  2. String id
)

Resolves a catalog by id from the registry, falling back to the bundled basicCatalog for the default id. Used by the a2ui() middleware.

Implementation

A2uiCatalog resolveCatalog(Registry registry, String id) {
  final found = registry.lookupValue<A2uiCatalog>(a2uiCatalogValueType, id);
  if (found != null) return found;
  if (id == defaultCatalogId) return basicCatalog;
  throw StateError(
    'a2ui(): no catalog registered under id "$id". '
    'Register one with loadCatalog(ai, id: "$id", catalog: ...) or use '
    'the default "$defaultCatalogId" catalog.',
  );
}