ExcludableEntity class
An example entity with fields that can be excluded from local/remote storage.
This class demonstrates how to use MapTarget in the toMap and diff
methods to control which fields are serialized for the local database versus
the remote server.
- Inheritance
-
- Object
- DatumEntityBase
- DatumEntity
- ExcludableEntity
Constructors
-
ExcludableEntity({required String id, required String userId, required String name, required DateTime modifiedAt, required DateTime createdAt, required int version, bool isDeleted = false, Map<
String, dynamic> ? localOnlyFields, Map<String, dynamic> ? remoteOnlyFields}) -
Creates an instance of ExcludableEntity.
const
-
ExcludableEntity.fromJson(Map<
String, dynamic> json) -
Creates an ExcludableEntity from a map (e.g., from JSON).
factory
Properties
- createdAt → DateTime
-
The timestamp of when this entity was first created.
final
- hashCode → int
-
The hash code for this object.
no setterinherited
- id → String
-
A unique identifier for the entity.
final
- isDeleted → bool
-
A flag indicating if this entity has been locally marked for deletion.
final
- isRelational → bool
-
Indicates whether this entity supports relationships. Always
falsefor this mixin.no setterinherited -
localOnlyFields
→ Map<
String, dynamic> ? -
A map of fields that should only be stored locally.
final
- modifiedAt → DateTime
-
The timestamp of the last time this entity was modified.
final
- name → String
-
A regular field that is always synchronized.
final
-
props
→ List<
Object?> -
Provides the list of properties to be used by the
Equatablemixin for value equality checks.no setteroverride -
remoteOnlyFields
→ Map<
String, dynamic> ? -
A map of fields that should only be sent to the remote.
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- stringify → bool
-
If set to
true, the toString method will be overridden to output this instance's props.no setter - userId → String
-
The ID of the user who owns or created this entity.
final
- version → int
-
A sequential integer used for optimistic concurrency and tracking
changes.
final
Methods
-
copyWith(
{DateTime? modifiedAt, int? version, bool? isDeleted, String? name, Map< String, dynamic> ? localOnlyFields, Map<String, dynamic> ? remoteOnlyFields}) → ExcludableEntity -
diff(
covariant DatumEntity oldVersion) → Map< String, dynamic> ? -
Creates a new instance of the entity with updated values.
Computes the difference between the current entity state and an
oldVersionof the entity.override -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toDatumMap(
{MapTarget target = MapTarget.local}) → Map< String, dynamic> -
Converts the entity to a
Map<String, dynamic>for persistence.override -
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited