resolve<T> method

T? resolve<T>(
  1. dynamic source, {
  2. dynamic key,
  3. dynamic args,
  4. T? defaultValue,
})

Executes sequence of functions to retrieve expected object. Look up in source for item via Parse.getArg and if object is not found then ControlFactory.get is executed with given key and args. Returns object from source or from factory store/initializers or defaultValue.

Control provides static call for this function via Control.inject.

nullable

Implementation

T? resolve<T>(dynamic source, {dynamic key, dynamic args, T? defaultValue}) {
  final item = Parse.getArg<T>(source, key: key);

  if (item != null) {
    inject(item, args: args);
    return item;
  }

  return get<T>(key: key, args: args) ?? defaultValue;
}