findSuperClass abstract method

Class? findSuperClass(
  1. Class parentClass, [
  2. bool declared = true
])

Finds the superclass of a given parentClass.

Parameters:

  • parentClass: The class whose superclass should be located.
  • declared: If true (default), returns the directly declared superclass only.
    If false, returns the nearest superclass in the hierarchy.

Returns:

  • The superclass Class instance, or null if none exists.

Example

final dogClass = await loader.loadClass<Dog>('com.example.Dog');
final superClass = loader.findSuperClass(dogClass);
print(superClass?.qualifiedName); // e.g., "com.example.Animal"

Usage Notes

  • Declared mode is useful for analyzing direct inheritance.
  • Non-declared mode is helpful for traversing extended hierarchies.

Implementation

Class? findSuperClass(Class parentClass, [bool declared = true]);