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.every(Iterable<TypeChecker> checkers)
Creates a new TypeChecker that delegates to other checkers.
const
factory
TypeChecker.fromName(String name, {bool ignoreGenerics, String? packageName})
Checks that the element has a specific name, and optionally checks that it is defined from a specific package.
const
factory
TypeChecker.fromPackage(String packageName)
Checks that the element comes from a specific package.
const
factory
TypeChecker.fromStatic(DartType type)
Create a new TypeChecker backed by a static type.
const
factory
TypeChecker.fromUrl(dynamic url)
Create a new TypeChecker backed by a library url.
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) → 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.
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