FieldDeclaration class abstract final

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

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

equalizedProperties() → List<Object?>
Mixin-style contract for value-based equality, hashCode, and toString.
inherited
getAnnotations() → List<AnnotationDeclaration>
Returns all annotations applied to this declaration in source code.
inherited
getDebugIdentifier() → String
Returns the stable debug identifier for this entity.
inherited
getIsAbstract() → bool
Indicates whether this member is declared as abstract.
inherited
getIsConst() → bool
Indicates whether this field is declared with the const modifier.
getIsFinal() → bool
Indicates whether this field is declared with the final modifier.
getIsLate() → bool
Indicates whether this field is declared with the late modifier.
getIsPublic() → bool
Indicates whether this declaration is publicly visible.
inherited
getIsStatic() → bool
Indicates whether this field is declared as static.
override
getIsSynthetic() → bool
Indicates whether this declaration is synthetic.
inherited
getIsTopLevel() → bool
Indicates whether this field is declared at the top level.
getLinkDeclaration() → LinkDeclaration
Returns the LinkDeclaration describing this field’s declared type.
getName() → String
Returns the simple (unqualified) name of this declaration.
inherited
getParentClass() → LinkDeclaration?
Returns a link to the class that declares this member.
inherited
getSourceLocation() → Uri?
Returns the URI pointing to the source location where this declaration is defined.
inherited
getType() → Type
Returns the Dart Type represented by this declaration.
inherited
getValue(dynamic instance) → dynamic
Returns the runtime value of this field from the given instance.
isFunction() → bool
Indicates whether this field’s declared type is a function type.
isNullable() → bool
Indicates whether this field’s declared type is nullable.
isRecord() → bool
Indicates whether this field’s type is a Dart record type.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
serialize(BinaryBuilder builder) → void
Serializes this declaration to binary format.
inherited
setValue(dynamic instance, dynamic value) → void
Sets the runtime value of this field on the given instance.
toJson() → Map<String, Object>
Serializes this declaration into a JSON-compatible map.
inherited
toString() → String
A string representation of this object.
inherited

Operators

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