toEntityReferenceList method

EntityReferenceList<T> toEntityReferenceList()

Returns this as an EntityReferenceList instance.

Implementation

EntityReferenceList<T> toEntityReferenceList() {
  var id = this.id;
  var entity = this.entity;

  EntitiesFetcher<T>? fetcher;

  var entityFetcher = _entityFetcher;
  if (entityFetcher != null) {
    fetcher =
        (ids, type) =>
            ids
                .map(
                  (id) => entityFetcher(id, type),
                ) // ignore: discarded_futures
                .toList()
                .resolveAll(); // ignore: discarded_futures
  }

  return EntityReferenceList<T>._(
    type,
    null,
    id == null ? null : [id],
    entity == null ? null : [entity],
    null,
    entityHandler,
    entityProvider,
    _entityHandlerProvider,
    fetcher,
    _entityCache,
    false,
  );
}