Typed<T extends Object>.of constructor

const Typed<T extends Object>.of(
  1. List<Object> typeArguments, {
  2. String? on,
})

A constructor for a type with any type parameters as type arguments.

This should be used when you wish to flow a type parameter from the host component to a child directive.

The following example demonstrates how ParentComponent's type parameter B can be flowed as a type argument to ChildComponent's type parameter A.

@Component(...)
class ChildComponent<A> {}

@Component(
  ...
  directives: [
    ChildComponent,
  ],
  directiveTypes: [
    Typed<ChildComponent>.of([#B]),
  ],
)
class ParentComponent<B> {}

Now if the directive type Typed<ParentComponent<String>>() is defined, the type argument will flow through and create a ChildComponent<String> as well.

See the typeArguments and on fields for details about these parameters.

Implementation

const Typed.of(
  List<Object> typeArguments, {
  this.on,
}) :
      // We prevent passing in a non-null value (because this constructor
      // requires an actual List). The compiler checks this field and whether
      // it is null (or not) to determine which constructor was used.
      // ignore: prefer_initializing_formals
      typeArguments = typeArguments;