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.name == 'Object' || other == this) return true;
  // Allow runtime hierarchy checks for interfaces/superclasses the native
  // enum implements (e.g. WidgetState implements WidgetStatesConstraint).
  // We delegate to BridgedClass.isAssignable using the underlying native
  // enum value, which mirrors how BridgedClass.isSubtypeOf handles
  // BridgedInstance values.
  if (other is BridgedClass && other.isAssignable != null) {
    final nativeValue =
        value is BridgedEnumValue ? value.nativeValue : value;
    if (nativeValue != null && other.isAssignable!(nativeValue)) {
      return true;
    }
  }
  return false;
}