identifyProperty<T, U extends ManagedObject> method Null safety

KeyPath identifyProperty<T, U extends ManagedObject>(
  1. T propertyIdentifier(
    1. U? x
    )
)

Returns a property selected by propertyIdentifier.

Invokes identifyProperties with propertyIdentifier, and ensures that a single property on this entity was selected. Returns that property.

Implementation

KeyPath identifyProperty<T, U extends ManagedObject>(
  T Function(U? x) propertyIdentifier,
) {
  final properties = identifyProperties(propertyIdentifier);
  if (properties.length != 1) {
    throw ArgumentError(
      "Invalid property selector. Must reference a single property only.",
    );
  }

  return properties.first;
}