getFields abstract method

List<Field> getFields()

Gets all fields declared in this class.

Returns:

  • List of all fields (instance and static)
  • Empty list if no fields exist

Example:

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

final fields = Class.forType<Person>().getFields();
print(fields.map((f) => f.name)); // ['name', 'count']

Includes:

  • Instance fields
  • Static fields
  • Final fields
  • Late fields

Excludes:

  • Inherited fields

Implementation

List<Field> getFields();