ClassElement class abstract

An element that represents a class or a mixin. The class can be defined by either a class declaration (with a class body), a mixin application (without a class body), a mixin declaration, or an enum declaration.

Clients may not extend, implement or mix-in this class.

Implemented types

Constructors

ClassElement()

Properties

accessors List<PropertyAccessorElement>
Return a list containing all of the accessors (getters and setters) declared in this class.
no setter
allSupertypes List<InterfaceType>
Return a list containing all the supertypes defined for this class and its supertypes. This includes superclasses, mixins, interfaces and superclass constraints.
no setter
constructors List<ConstructorElement>
Return a list containing all of the constructors declared in this class. The list will be empty if there are no constructors defined for this class, as is the case when this element represents an enum or a mixin.
no setter
context → AnalysisContext
Return the analysis context in which this element is defined.
no setterinherited
declaration Element
Return the declaration of this element. If the element is a view on an element, e.g. a method from an interface type, with substituted type parameters, return the corresponding element from the class, without any substitutions. If this element is already a declaration (or a synthetic element, e.g. a synthetic property accessor), return itself.
no setterinherited
displayName String
Return the display name of this element, possibly the empty string if this element does not have a name.
no setteroverride
documentationComment String?
Return the content of the documentation comment (including delimiters) for this element, or null if this element does not or cannot have documentation.
no setterinherited
enclosingElement CompilationUnitElement
Return the element that either physically or logically encloses this element. This will be null if this element is a library because libraries are the top-level elements in the model.
no setteroverride
fields List<FieldElement>
Return a list containing all of the fields declared in this class.
no setter
hasAlwaysThrows bool
Return true if this element has an annotation of the form @alwaysThrows.
no setterinherited
hasDeprecated bool
Return true if this element has an annotation of the form @deprecated or @Deprecated('..').
no setterinherited
hasDoNotStore bool
Return true if this element has an annotation of the form @doNotStore.
no setterinherited
hasFactory bool
Return true if this element has an annotation of the form @factory.
no setterinherited
hashCode int
The hash code for this object.
no setterinherited
hasInternal bool
Return true if this element has an annotation of the form @internal.
no setterinherited
hasIsTest bool
Return true if this element has an annotation of the form @isTest.
no setterinherited
hasIsTestGroup bool
Return true if this element has an annotation of the form @isTestGroup.
no setterinherited
hasJS bool
Return true if this element has an annotation of the form @JS(..).
no setterinherited
hasLiteral bool
Return true if this element has an annotation of the form @literal.
no setterinherited
hasMustCallSuper bool
Return true if this element has an annotation of the form @mustCallSuper.
no setterinherited
hasNonFinalField bool
Return true if this class or its superclass declares a non-final instance field.
no setter
hasNonVirtual bool
Return true if this element has an annotation of the form @nonVirtual.
no setterinherited
hasOptionalTypeArgs bool
Return true if this element has an annotation of the form @optionalTypeArgs.
no setterinherited
hasOverride bool
Return true if this element has an annotation of the form @override.
no setterinherited
hasProtected bool
Return true if this element has an annotation of the form @protected.
no setterinherited
hasRequired bool
Return true if this element has an annotation of the form @required.
no setterinherited
hasSealed bool
Return true if this element has an annotation of the form @sealed.
no setterinherited
hasStaticMember bool
Return true if this class declares a static member.
no setter
hasUseResult bool
Return true if this element has an annotation of the form @useResult or @UseResult('..').
no setterinherited
hasVisibleForOverriding bool
Return true if this element has an annotation of the form @visibleForOverriding.
no setterinherited
hasVisibleForTemplate bool
Return true if this element has an annotation of the form @visibleForTemplate.
no setterinherited
hasVisibleForTesting bool
Return true if this element has an annotation of the form @visibleForTesting.
no setterinherited
id int
The unique integer identifier of this element.
no setterinherited
interfaces List<InterfaceType>
Return a list containing all of the interfaces that are implemented by this class.
no setter
isAbstract bool
Return true if this class is abstract. A class is abstract if it has an explicit abstract modifier or if it is implicitly abstract, such as a class defined by a mixin declaration. Note, that this definition of abstract is different from has unimplemented members.
no setter
isDartCoreObject bool
Return true if this class represents the class 'Object' defined in the dart:core library.
no setter
isEnum bool
Return true if this class is defined by an enum declaration.
no setter
isMixin bool
Return true if this class is defined by a mixin declaration.
no setter
isMixinApplication bool
Return true if this class is a mixin application. A class is a mixin application if it was declared using the syntax "class A = B with C;".
no setter
isPrivate bool
Return true if this element is private. Private elements are visible only within the library in which they are declared.
no setterinherited
isPublic bool
Return true if this element is public. Public elements are visible within any library that imports the library in which they are declared.
no setterinherited
isSimplyBounded bool
If the element defines a type, indicates whether the type may safely appear without explicit type parameters as the bounds of a type parameter declaration.
no setterinherited
isSynthetic bool
Return true if this element is synthetic. A synthetic element is an element that is not represented in the source code explicitly, but is implied by the source code, such as the default constructor for a class that does not explicitly define any constructors.
no setterinherited
isValidMixin bool
Return true if this class can validly be used as a mixin when defining another class. For classes defined by a mixin declaration, the result is always true. For classes defined by a class declaration or a mixin application, the behavior of this method is defined by the Dart Language Specification in section 9:
no setter
kind ElementKind
Return the kind of element that this is.
no setterinherited
library LibraryElement
Return the library that contains this element. This will be the element itself if it is a library element. This will be null if this element is MultiplyDefinedElement that is not contained in a library.
no setterinherited
librarySource → Source
If this target is associated with a library, return the source of the library's defining compilation unit; otherwise return null.
no setterinherited
location ElementLocation?
Return an object representing the location of this element in the element model. The object can be used to locate this element at a later time.
no setterinherited
metadata List<ElementAnnotation>
Return a list containing all of the metadata associated with this element. The array will be empty if the element does not have any metadata or if the library containing this element has not yet been resolved.
no setterinherited
methods List<MethodElement>
Return a list containing all of the methods declared in this class.
no setter
mixins List<InterfaceType>
Return a list containing all of the mixins that are applied to the class being extended in order to derive the superclass of this class.
no setter
name String
Return the name of this element, or null if this element does not have a name.
no setteroverride
nameLength int
Return the length of the name of this element in the file that contains the declaration of this element, or 0 if this element does not have a name.
no setterinherited
nameOffset int
Return the offset of the name of this element in the file that contains the declaration of this element, or -1 if this element is synthetic, does not have a name, or otherwise does not have an offset.
no setterinherited
nonSynthetic Element
Return the non-synthetic element that caused this element to be created.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
session AnalysisSession?
Return the analysis session in which this element is defined.
no setterinherited
source → Source
Return the source associated with this target, or null if this target is not associated with a source.
no setterinherited
superclassConstraints List<InterfaceType>
Return a list containing all of the superclass constraints defined for this class. The list will be empty if this class does not represent a mixin declaration. If this class does represent a mixin declaration but the declaration does not have an on clause, then the list will contain the type for the class Object.
no setter
supertype InterfaceType?
Return the superclass of this class, or null if either the class represents the class 'Object' or if the class represents a mixin declaration. All other classes will have a non-null superclass. If the superclass was not explicitly declared then the implicit superclass 'Object' will be returned.
no setter
thisType InterfaceType
Return the type of this expression for this class.
no setter
typeParameters List<TypeParameterElement>
Return a list containing all of the type parameters declared by this element directly. This does not include type parameters that are declared by any enclosing elements.
no setterinherited
unnamedConstructor ConstructorElement?
Return the unnamed constructor declared in this class, or null if either this class does not declare an unnamed constructor but does declare named constructors or if this class represents a mixin declaration. The returned constructor will be synthetic if this class does not declare any constructors, in which case it will represent the default constructor for the class.
no setter

Methods

accept<T>(ElementVisitor<T> visitor) → T?
Use the given visitor to visit this element. Return the value returned by the visitor as a result of visiting this element.
inherited
getDisplayString({required bool withNullability, bool multiline = false}) String
Return the presentation of this element as it should appear when presented to users.
inherited
getExtendedDisplayName(String? shortName) String
Return a display name for the given element that includes the path to the compilation unit in which the type is defined. If shortName is null then displayName will be used as the name of this element. Otherwise the provided name will be used.
inherited
getField(String name) FieldElement?
Return the field (synthetic or explicit) defined in this class that has the given name, or null if this class does not define a field with the given name.
getGetter(String name) PropertyAccessorElement?
Return the element representing the getter with the given name that is declared in this class, or null if this class does not declare a getter with the given name.
getMethod(String name) MethodElement?
Return the element representing the method with the given name that is declared in this class, or null if this class does not declare a method with the given name.
getNamedConstructor(String name) ConstructorElement?
Return the named constructor declared in this class with the given name, or null if this class does not declare a named constructor with the given name.
getSetter(String name) PropertyAccessorElement?
Return the element representing the setter with the given name that is declared in this class, or null if this class does not declare a setter with the given name.
instantiate({required List<DartType> typeArguments, required NullabilitySuffix nullabilitySuffix}) InterfaceType
Create the InterfaceType for this class with the given typeArguments and nullabilitySuffix.
isAccessibleIn(LibraryElement? library) bool
Return true if this element, assuming that it is within scope, is accessible to code in the given library. This is defined by the Dart Language Specification in section 3.2:
inherited
lookUpConcreteMethod(String methodName, LibraryElement library) MethodElement?
Return the element representing the method that results from looking up the given methodName in this class with respect to the given library, ignoring abstract methods, or null if the look up fails. The behavior of this method is defined by the Dart Language Specification in section 16.15.1:
lookUpGetter(String getterName, LibraryElement library) PropertyAccessorElement?
Return the element representing the getter that results from looking up the given getterName in this class with respect to the given library, or null if the look up fails. The behavior of this method is defined by the Dart Language Specification in section 16.15.2:
lookUpInheritedConcreteGetter(String getterName, LibraryElement library) PropertyAccessorElement?
Return the element representing the getter that results from looking up the given getterName in the superclass of this class with respect to the given library, ignoring abstract getters, or null if the look up fails. The behavior of this method is defined by the Dart Language Specification in section 16.15.2:
lookUpInheritedConcreteMethod(String methodName, LibraryElement library) MethodElement?
Return the element representing the method that results from looking up the given methodName in the superclass of this class with respect to the given library, ignoring abstract methods, or null if the look up fails. The behavior of this method is defined by the Dart Language Specification in section 16.15.1:
lookUpInheritedConcreteSetter(String setterName, LibraryElement library) PropertyAccessorElement?
Return the element representing the setter that results from looking up the given setterName in the superclass of this class with respect to the given library, ignoring abstract setters, or null if the look up fails. The behavior of this method is defined by the Dart Language Specification in section 16.15.2:
lookUpInheritedMethod(String methodName, LibraryElement library) MethodElement?
Return the element representing the method that results from looking up the given methodName in the superclass of this class with respect to the given library, or null if the look up fails. The behavior of this method is defined by the Dart Language Specification in section 16.15.1:
lookUpMethod(String methodName, LibraryElement library) MethodElement?
Return the element representing the method that results from looking up the given methodName in this class with respect to the given library, or null if the look up fails. The behavior of this method is defined by the Dart Language Specification in section 16.15.1:
lookUpSetter(String setterName, LibraryElement library) PropertyAccessorElement?
Return the element representing the setter that results from looking up the given setterName in this class with respect to the given library, or null if the look up fails. The behavior of this method is defined by the Dart Language Specification in section 16.15.2:
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
thisOrAncestorMatching<E extends Element>(Predicate<Element> predicate) → E?
Return either this element or the most immediate ancestor of this element for which the predicate returns true, or null if there is no such element.
inherited
thisOrAncestorOfType<E extends Element>() → E?
Return either this element or the most immediate ancestor of this element that has the given type, or null if there is no such element.
inherited
toString() String
A string representation of this object.
inherited
visitChildren(ElementVisitor visitor) → void
Use the given visitor to visit all of the children of this element. There is no guarantee of the order in which the children will be visited.
inherited

Operators

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