ensureIsSubTypeOf<Parent extends Object> function

void ensureIsSubTypeOf<Parent extends Object>(
  1. Type objectType
)

Implementation

void ensureIsSubTypeOf<Parent extends Object>(Type objectType) {
  try {
    final type = reflectType(objectType);
    if (type.superclass!.reflectedType != Parent) throw Exception();
  } catch (e) {
    throw ArgumentError.value(objectType, 'Invalid Type provided',
        'Ensure your class extends `$Parent` class');
  }
}