register method

void register(
  1. dynamic locator,
  2. dynamic factory(
    1. dynamic locator

Registers a component using a factory method.

  • locator a locator to identify component to be created.
  • factory a factory function that receives a locator and returns a created component.


void register(locator, factory(locator)) {
  if (locator == null) throw Exception('Locator cannot be null');
  if (factory == null) throw Exception('Factory cannot be null');

  _registrations.add(Registration(locator, factory));