isAssignableTo abstract method

bool isAssignableTo(
  1. DartType leftType,
  2. DartType rightType
)

Return true if the leftType is assignable to the rightType.

For the Dart 2.0 type system, the definition of this relationship is given in the Dart Language Specification, section 19.4 Subtypes:

A type T may be assigned to a type S in an environment Γ, written Γ ⊢ TS, iff either Γ ⊢ S <: T or Γ ⊢ T <: S. In this case we say that the types S and T are assignable.

The subtype relationship (<:) can be tested using isSubtypeOf.

Other type systems may define this operation differently. In particular, while the operation is commutative in the Dart 2.0 type system, it will not be commutative when NNBD is enabled, so the order of the arguments is important.

Implementation

bool isAssignableTo(DartType leftType, DartType rightType);