FieldDeclaration class abstract

Represents a field (variable) declared within a Dart class, extension, enum, or mixin.

Provides access to its type, modifiers (final, late, const, static), and the ability to read or write its value at runtime.

Example

class Person {
  final String name;
  static int count = 0;
}

final field = reflector.reflectField(Person, 'name');
print(field.getIsFinal()); // true
print(field.getTypeDeclaration().getName()); // String

final p = Person('Jet');
print(field.getValue(p)); // Jet
Inheritance

Constructors

FieldDeclaration()
Represents a field (variable) declared within a Dart class, extension, enum, or mixin.
const

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

getAnnotations() List<AnnotationDeclaration>
Returns all annotations applied to this declaration.
inherited
getDartType() → DartType?
The analyzer DartType of the entity for enhanced type operations.
inherited
getDebugIdentifier() String
The debug identifier for the entity.
inherited
getElement() → Element?
The analyzer element associated with this declaration.
inherited
getIsAbstract() bool
Returns true if this member is declared abstract.
inherited
getIsConst() bool
Whether this field is declared const.
getIsFinal() bool
Whether this field is declared final.
getIsLate() bool
Whether this field is declared late.
getIsPublic() bool
Checks if this declaration is a public declaration.
inherited
getIsStatic() bool
Whether this field is static.
override
getIsSynthetic() bool
Checks if a declaration is a synthetic declaration.
inherited
getLinkDeclaration() LinkDeclaration
Returns the LinkDeclaration of this field.
getName() String
Gets the name of the declared element.
inherited
getParentClass() LinkDeclaration?
Returns the LinkDeclaration that owns this member.
inherited
getParentLibrary() LibraryDeclaration
Returns the LibraryDeclaration in which this declaration is defined.
inherited
getSourceLocation() Uri?
Returns the source code location (e.g., file path or URI) where this declaration is defined, or null if not available in the current reflection context.
inherited
getType() Type
Gets the runtime type of the declared element.
inherited
getValue(dynamic instance) → dynamic
Returns the value of this field on the given instance.
hasAnalyzerSupport() bool
Returns true if this declaration has analyzer information available.
inherited
isNullable() bool
Returns true if the field is nullable.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
setValue(dynamic instance, dynamic value) → void
Sets the value of this field on the given instance.
toJson() Map<String, Object>
Returns a JSON representation of this entity.
inherited
toString() String
A string representation of this object.
inherited

Operators

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