sorted property

Iterable<FieldElement> sorted

Returns a Set of all instance FieldElement items for element and super classes, sorted first by their location in the inheritance hierarchy (super first) and then by their location in the source file.

Implementation

Iterable<FieldElement> get sorted {
  // Get all of the fields that need to be assigned
  final elementInstanceFields =
      Map.fromEntries(element.fields.where((e) => !e.isStatic).map((e) => MapEntry(e.name, e)));

  final inheritedFields = <String, FieldElement>{};

  // Get the list of all fields for `element`
  final allFields = elementInstanceFields.keys.toSet().union(inheritedFields.keys.toSet());

  final fields =
      allFields.map((e) => _FieldSet(elementInstanceFields[e], inheritedFields[e])).toList();

  // Sort the fields using the `compare` implementation in _FieldSet
  fields.sort();

  return fields.map((fs) => fs.field).toList();
}