defaultProperties property Null safety

List<String>? defaultProperties

The list of default property names of this object.

By default, a Query will fetch the properties in this list. You may specify a different set of properties by setting the Query.returningProperties value. The default set of properties is a list of all attributes that do not have the Column.shouldOmitByDefault flag set in their Column and all ManagedRelationshipType.belongsTo relationships.

This list cannot be modified.

Implementation

List<String>? get defaultProperties {
  if (_defaultProperties == null) {
    final elements = <String?>[];
    elements.addAll(attributes.values
        .where((prop) => prop!.isIncludedInDefaultResultSet)
        .where((prop) => !prop!.isTransient)
        .map((prop) => prop!.name));

    elements.addAll(relationships!.values
        .where((prop) =>
            prop!.isIncludedInDefaultResultSet &&
            prop.relationshipType == ManagedRelationshipType.belongsTo)
        .map((prop) => prop!.name));
    _defaultProperties = List.unmodifiable(elements);
  }
  return _defaultProperties;
}