TypeDeclaration constructor
const
TypeDeclaration()
Represents metadata information about any Dart type — including classes,
enums, typedefs, generic types like List<int>
, and even nullable types.
You can use this class to:
- Introspect type names and type arguments
- Determine type kind (list, map, class, enum, etc.)
- Resolve the declaration (e.g., to ClassDeclaration or EnumDeclaration)
- Perform runtime type comparisons or assignability checks
Example
final type = reflector.reflectType(MyClass);
print(type.getName()); // MyClass
if (type.asClassType() != null) {
final reflectedClass = type.asClassType()!;
print(reflectedClass.getConstructors());
}
Implementation
const TypeDeclaration();