isSubtypeOf method

  1. @override
bool isSubtypeOf(
  1. RuntimeType other, {
  2. Object? value,
})
override

Checks if this type is a subtype of other.

Implementation

@override
bool isSubtypeOf(RuntimeType other, {Object? value}) {
  if (other is AppliedRuntimeType) {
    if (!_runtimeTypeCompatible(baseType, other.baseType)) return false;
    // Only compare arguments when both sides declare the same arity; a
    // mismatch stays permissive so partially-applied annotations don't fail.
    if (typeArguments.length != other.typeArguments.length) return true;
    for (var i = 0; i < typeArguments.length; i++) {
      final theirs = other.typeArguments[i];
      if (_isWildcardTypeName(theirs.name)) continue;
      if (!_runtimeTypeCompatible(typeArguments[i], theirs)) return false;
    }
    return true;
  }
  // Comparing an applied type against a raw base / structural type: match on
  // the base type only.
  return _runtimeTypeCompatible(baseType, other);
}