typeDeclarationOf function

Element? typeDeclarationOf(
  1. DartObject value
)

Returns the element representing the declaration of value's type.

May return null if value isn't a valid constant expression or has an unknown type.

Implementation

Element? typeDeclarationOf(DartObject value) {
  var function = value.toFunctionValue();
  if (function != null) return function;

  // For functions, `toTypeValue()` is null so we fall back on `type`.
  final type = value.toTypeValue() ?? value.type;
  return type?.element;
}