initialize method

  1. @protected
Relationship<E, N> initialize({
  1. required String ownerKey,
  2. required String name,
  3. String? inverseName,
})

Initializes this relationship (typically when initializing the owner in DataModelMixin) by supplying the owner, and related metadata.

Implementation

@protected
Relationship<E, N> initialize(
    {required final String ownerKey,
    required final String name,
    final String? inverseName}) {
  // If the relationship owner key is same as previous, return
  if (_ownerKey != null && _ownerKey == ownerKey) return this;

  _ownerKey = ownerKey;
  _name = name;
  _inverseName = inverseName;

  if (_uninitializedKeys == null) {
    return this;
  }

  // setting up from scratch, remove all and add keys

  _removeAll(notify: false);
  _addAll(_uninitializedKeys!, notify: false);

  _uninitializedKeys!.clear();

  return this;
}