register method

  1. @override
void register(
  1. ModuleRegistry registry
)
override

Registers the values and bindings owned by this module.

Implementation

@override
void register(ModuleRegistry registry) {
  final identities = <(Type, String)>{
    for (final component in registry.bindings<MdcComponentBinding>())
      (component.rendererType, component.name),
  };
  for (final component in components) {
    if (component.name.isEmpty) {
      throw ArgumentError.value(
        component.name,
        'components',
        'An MDC component name cannot be empty.',
      );
    }
    final identity = (component.rendererType, component.name);
    if (!identities.add(identity)) {
      throw StateError(
        'MDC component "${component.name}" is already registered for '
        '${component.rendererType}.',
      );
    }
  }

  mdcParserKey.provide(registry, parser);
  for (final component in components) {
    registry.bind(component);
  }
}