extractProviderObjects method

Iterable<DartObject> extractProviderObjects(
  1. DartObject? value
)

Helper method that can recursively extract DartObjects for Provider.

A value can be one of four (4) things:

  • A constant instance of Type (implicit Provider)
  • A constant instance of Provider
  • A constant List of any of the above types, including other lists.
  • A constant Module, which has its own way of collecting these objects.

NOTE: That the implicit conversion of Type to Provider is expected to happen elsewhere, this function is just a convenience for dealing with Module versus List in the view compiler.

Returns a lazy iterable of only Type or Provider objects.

Implementation

Iterable<DartObject> extractProviderObjects(DartObject? value) {
  // Guard against being passed a null field.
  if (value == null || value.isNull) {
    return const [];
  }
  if (isList(value)) {
    return _extractProvidersFromList(value);
  }
  if (isModule(value)) {
    return _extractProvidersFromModule(value);
  }
  return [value];
}