type property Null safety

DartType? type

Return a representation of the type of the object being represented.

For values resulting from the invocation of a 'const' constructor, this will be a representation of the run-time type of the object.

For values resulting from a literal expression, this will be a representation of the static type of the value -- int for integer literals, List for list literals, etc. -- even when the static type is an abstract type (such as List) and hence will never be the run-time type of the represented object.

For values resulting from any other kind of expression, this will be a representation of the result of evaluating the expression.

Return null if the expression cannot be evaluated, either because it is not a valid constant expression or because one or more of the values used in the expression does not have a known value.

This method can return a representation of the type, even if this object would return false from hasKnownValue.

Implementation

DartType? get type;