create method

  1. @override
dynamic create(
  1. dynamic locator
)
override

Creates a component identified by given locator.

  • locator a locator to identify component to be created. Return the created component.

Trows a CreateException if the factory is not able to create the component.

Implementation

@override
dynamic create(locator) {
  if (locator == null) {
    throw Exception('Locator cannot be null');
  }

  // Iterate from the latest factories
  for (var index = _factories.length - 1; index >= 0; index--) {
    var factory = _factories[index];
    if (factory.canCreate(locator) != null) {
      return factory.create(locator);
    }
  }

  throw CreateException(null, locator);
}