create<Service> method

Service create<Service>(
  1. [String name]

Create a Service instance for the current state.

If multiple Services are registered, a name can be provided to identify the needed service.


Service create<Service>([String name]) {
  final byType = _instanciators[Service];
  if (byType == null) {
    throw Exception('No registered service for type $Service');
  final serviceBuilder = byType[name ?? _defaultName];
  if (serviceBuilder == null) {
    throw Exception(
        'No registered service for type $Service with name "$name"');
  return serviceBuilder(_state()) as Service;