ContextualResourceResolver<T, C extends Comparable<C>> constructor

ContextualResourceResolver<T, C extends Comparable<C>>({
  1. Map<String, dynamic>? resources,
  2. Comparator<C>? contextComparator,
  3. C? defaultContext,
  4. ContextualResource<T, C>? defaultResource,
})

Implementation

ContextualResourceResolver(
    {Map<String, dynamic>? resources,
    this.contextComparator,
    this.defaultContext,
    this.defaultResource}) {
  if (resources != null) {
    for (var entry in resources.entries) {
      var k = entry.key;
      var v = entry.value;

      if (v is ContextualResource) {
        add(k, [v as ContextualResource<T, C>]);
      } else if (v is Iterable) {
        add(k, v as Iterable<ContextualResource<T, C>>);
      } else if (v is Function) {
        var val = v();
        addDynamic(k, val);
      }
    }
  }
}