DependencyConfig.fromJson constructor

DependencyConfig.fromJson(
  1. Map json
)

Implementation

factory DependencyConfig.fromJson(Map<dynamic, dynamic> json) {
  ModuleConfig? moduleConfig;
  DisposeFunctionConfig? disposeFunction;

  List<ImportableType> dependsOn = [];
  List<InjectedDependency> dependencies = [];

  if (json['moduleConfig'] != null) {
    moduleConfig = ModuleConfig.fromJson(json['moduleConfig']);
  }

  if (json['disposeFunction'] != null) {
    disposeFunction = DisposeFunctionConfig.fromJson(json['disposeFunction']);
  }

  if (json['dependencies'] != null) {
    json['dependencies'].forEach((v) {
      dependencies.add(InjectedDependency.fromJson(v));
    });
  }

  if (json['dependsOn'] != null) {
    json['dependsOn'].forEach((v) {
      dependsOn.add(ImportableType.fromJson(v));
    });
  }

  return DependencyConfig(
    type: ImportableType.fromJson(json['type']),
    typeImpl: ImportableType.fromJson(json['typeImpl']),
    dependencies: dependencies,
    injectableType: json['injectableType'],
    instanceName: json['instanceName'],
    signalsReady: json['signalsReady'],
    environments: json['environments']?.cast<String>(),
    constructorName: json['constructorName'],
    isAsync: json['isAsync'] as bool,
    dependsOn: dependsOn,
    preResolve: json['preResolve'] as bool,
    moduleConfig: moduleConfig,
    disposeFunction: disposeFunction,
  );
}