TypeChecker class abstract

An abstraction around doing static type checking at compile/build time.

Constructors

TypeChecker.any(Iterable<TypeChecker> checkers)
Creates a new TypeChecker that delegates to other checkers.
const
factory
TypeChecker.fromDart(String type, {required String package})
Create a new TypeChecker for a dart package type.
const
factory
TypeChecker.fromPackage(String type, {required String package})
Create a new TypeChecker from a type name and respective package name
const
factory
TypeChecker.fromStatic(DartType type)
Create a new TypeChecker backed by a static type.
const
factory

Properties

hashCode → int
The hash code for this object.
no setterinherited
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited

Methods

annotationsOf(Element element, {bool throwOnUnresolved = true}) → Iterable<DartObject>
Returns annotating constants on element assignable to this type.
annotationsOfExact(Element element, {bool throwOnUnresolved = true}) → Iterable<DartObject>
Returns annotating constants on element of exactly this type.
firstAnnotationOf(Element element, {bool throwOnUnresolved = true}) → DartObject?
Returns the first constant annotating element assignable to this type.
firstAnnotationOfExact(Element element, {bool throwOnUnresolved = true}) → DartObject?
Returns the first constant annotating element that is exactly this type.
hasAnnotationOf(Element element, {bool throwOnUnresolved = true}) → bool
Returns if a constant annotating element is assignable to this type.
hasAnnotationOfExact(Element element, {bool throwOnUnresolved = true}) → bool
Returns if a constant annotating element is exactly this type.
isAssignableFrom(Element? element) → bool
Returns true if the type of element can be assigned to this type.
isAssignableFromType(DartType? staticType, {List<TypeChecker> args = const []}) → bool
Returns true if staticType can be assigned to this type.
isExactly(Element? element) → bool
Returns true if representing the exact same class as element.
isExactlyType(DartType? staticType) → bool
Returns true if representing the exact same type as staticType.
isNotAssignableFrom(Element? element) → bool
Returns true if the type of element can NOT be assigned to this type.
isNotAssignableFromType(DartType? staticType, {List<TypeChecker> args = const []}) → bool
Returns true if staticType can NOT be assigned to this type.
isSuperOf(Element element) → bool
Returns true if representing a super class of element.
isSuperTypeOf(DartType staticType) → bool
Returns true if representing a super type of staticType.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() → String
A string representation of this object.
inherited

Operators

operator ==(Object other) → bool
The equality operator.
inherited