EntityReference<T> class
Reference wrapper to an entity.
- Inheritance
-
- Object
- EntityReferenceBase<
T> - EntityReference
- 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 theentity
instance. Seeentity
and isEntitySet. -
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). Seeid
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 entryEntityReference
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
-
entityHandler
→ EntityHandler<
T> ? -
The EntityHandler for this entity type.
no setterinherited
- entityOrID → Object?
-
Returns entity or id.
See isEntitySet and isIdSet.
no setter
- entityProvider → EntityProvider?
-
The EntityProvider for this entity type.
no setterinherited
- entityTime → DateTime?
-
The DateTime of when the entity was set.
no setter
- hashCode → int
-
The hash code for this object.
no setteroverride
- id → Object?
-
The entity ID or null if not resolved.
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;no setteroverride - isNotNull → bool
-
Returns
true
if this reference is NOTnull
.no setterinherited - isNull → bool
-
Returns
true
if this reference isnull
(no id or entity set).no setteroverride - 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.
-
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
-
getNotNull(
) → FutureOr< T> -
Same as get but won't return
null
.override -
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
-
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 currentid
. 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