EntityReference<T> class

Reference wrapper to an entity.

Inheritance
Available extensions

Constructors

EntityReference.asNull({Type? type, String? typeName, EntityHandler<T>? entityHandler, EntityProvider? entityProvider, EntityHandlerProvider? entityHandlerProvider, EntityFetcher<T>? entityFetcher, EntityCache? entityCache, bool checkGenericType = true})
Creates an EntityReference with a null entity and null id. See isNull.
EntityReference.from(Object? o, {Type? type, String? typeName, EntityHandler<T>? entityHandler, EntityProvider? entityProvider, EntityHandlerProvider? entityHandlerProvider, EntityFetcher<T>? entityFetcher, EntityCache? entityCache})
Creates an EntityReference from o trying to resolve it in the best way.
factory
EntityReference.fromEntity(T? entity, {Type? type, String? typeName, EntityHandler<T>? entityHandler, EntityProvider? entityProvider, EntityHandlerProvider? entityHandlerProvider, EntityFetcher<T>? entityFetcher, EntityCache? entityCache, bool checkGenericType = true})
Creates an EntityReference with the entity instance. The id is resolved through the entity instance. See entity and isEntitySet.
EntityReference.fromEntityInstantiator(Object id, EntityInstantiator<T>? entityInstantiator, {Type? type, String? typeName, EntityHandler<T>? entityHandler, EntityProvider? entityProvider, EntityHandlerProvider? entityHandlerProvider, EntityFetcher<T>? entityFetcher, EntityCache? entityCache, bool checkGenericType = true})
Creates an EntityReference with an entity instance created from entityInstantiator.
EntityReference.fromEntityMap(Map<String, dynamic>? entityMap, {Type? type, String? typeName, EntityHandler<T>? entityHandler, EntityProvider? entityProvider, EntityHandlerProvider? entityHandlerProvider, EntityFetcher<T>? entityFetcher, EntityCache? entityCache, bool checkGenericType = true})
Creates an EntityReference with an entity instance from entityMap.
EntityReference.fromID(Object? id, {Type? type, String? typeName, EntityHandler<T>? entityHandler, EntityProvider? entityProvider, EntityHandlerProvider? entityHandlerProvider, EntityFetcher<T>? entityFetcher, EntityCache? entityCache, bool checkGenericType = true})
Creates an EntityReference with the entity id (without a loaded entity instance). See id and isIdSet.
EntityReference.fromJson(Map<String, dynamic> json, {Type? type, String? typeName, EntityHandler<T>? entityHandler, EntityProvider? entityProvider, EntityHandlerProvider? entityHandlerProvider, EntityFetcher<T>? entityFetcher, EntityCache? entityCache})
Creates an EntityReference from a JSON Map. If json has an entry EntityReference it will be treated as a Map from toJson, otherwise will be treated as an entity JSON (a Map from entityToJson) and instantiated through fromEntityMap.
factory

Properties

currentValue Object?
Returns the current internal value (entity OR id).
no setteroverride
entity → T?
The already loaded entity.
no setter
entity → T?

Available on EntityReference<T>?, provided by the NullEntityReferenceExtension extension

no setter
entityHandler EntityHandler<T>?
The EntityHandler for this entity type.
no setterinherited
entityOrID Object?
Returns entity or id. See isEntitySet and isIdSet.
no setter
entityOrID Object?

Available on EntityReference<T>?, provided by the NullEntityReferenceExtension extension

no setter
entityProvider EntityProvider?
The EntityProvider for this entity type.
no setterinherited
entityTime DateTime?
The DateTime of when the entity was set.
no setter
hasEntity bool
Returns true if isEntitySet or hasEntityInstantiator.
no setter
hasEntityInstantiator bool
Returns true if the entity has an EntityInstantiator not called yet. If an EntityInstantiator is defined isIdSet also should be defined.
no setter
hashCode int
The hash code for this object.
no setteroverride
id Object?
The entity ID or null if not resolved.
no setter
id Object?

Available on EntityReference<T>?, provided by the NullEntityReferenceExtension extension

no setter
idAsInt int?
Returns id as int or null. See idNotNullAs.
no setter
idNotNull Object
Returns id as Object (NOT null).
no setter
idNotNullAsInt int
Returns id as int. See idAsInt.
no setter
isEntitySet bool
Returns true if the entity instance is loaded.
no setter
isIdSet bool
Returns true if id is set.
no setter
isLoaded bool
Returns true if the entity is loaded. See hasEntity.
no setteroverride
isLoaded bool

Available on EntityReferenceBase<T>?, provided by the NullEntityReferenceBaseExtension extension

no setter
isNotNull bool
Returns true if this reference is NOT null.
no setterinherited
isNotNull bool

Available on EntityReferenceBase<T>?, provided by the NullEntityReferenceBaseExtension extension

no setter
isNull bool
Returns true if this reference is null (no id or entity set).
no setteroverride
isNull bool

Available on EntityReferenceBase<T>?, provided by the NullEntityReferenceBaseExtension extension

no setter
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
type Type
The entity Type.
no setteroverride
typeName String
The entity Type name.
no setteroverride

Methods

cast<E>({bool checkGenericType = true}) EntityReference<E>
override
copy({bool withEntity = true}) EntityReference<T>
Returns a copy of this EntityReference instance.
override
disposeEntity() → T?
Disposes the current loaded entity instance and returns it. Id id is defined it will keep it.
disposeInternalHandlers() → void
Disposes internal objects that are not necessary after resolve this instance. Useful when passing this instance to another Isolate.
override
entityOrIdToJson() Object?
Encodes entity or id as JSON. If isNull returns null.
entityToJson([JsonEncoder? jsonEncoder]) Map<String, dynamic>?
Returns entity as a JSON Map.
equalsEntityID(Object? otherEntity) bool?
fetchImpl() FutureOr<T?>
Fetches the entity, but won't set it. Do not call this directly.
get() FutureOr<T?>
Returns the current entity or fetches it.
override
get() FutureOr<T?>

Available on EntityReference<T>?, provided by the NullEntityReferenceExtension extension

getNotNull() FutureOr<T>
Same as get but won't return null.
override
getNotNull() FutureOr<T?>

Available on EntityReference<T>?, provided by the NullEntityReferenceExtension extension

idAs<I>() → I?
Returns id as I or null. See idNotNullAs.
idNotNullAs<I>() → I
Returns id as I. See idAs.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
refresh() FutureOr<T?>
Refreshes the entity fetching it.
override
resolve() → void
Ensures that this instance is resolved. See disposeInternalHandlers.
override
set(T? o) → T?
Sets the entity to o and returns the current entity.
setID(Object? id) Object?
Sets the entity id and returns the current id. If the ID is changing the previous loaded entity instance is disposed.
toEntityReferenceList() EntityReferenceList<T>
Returns this as an EntityReferenceList instance.
toJson([JsonEncoder? jsonEncoder]) Map<String, dynamic>?
Encodes this EntityReference instance to JSON.
override
toString({bool withT = true}) String
A string representation of this object.
override
updateIdFromEntity() bool
Updates id from entity instance ID.

Operators

operator ==(Object other) bool
The equality operator.
override