PrismSyncPhase enum
The state of a background synchronisation, as PrismSyncStatus needs it.
Prism deliberately does not depend on a sync package, so this is a plain
value type rather than an interface to implement. Adapting your engine is a
few lines, and because flutter_local_first's SyncState is sealed the
compiler checks that your adapter handles every case:
PrismSyncSnapshot snapshotOf(SyncState state) => switch (state) {
Idle() => const PrismSyncSnapshot.idle(),
Offline(:final pendingChanges) =>
PrismSyncSnapshot(phase: PrismSyncPhase.offline, pendingChanges: pendingChanges),
Stopped() => const PrismSyncSnapshot(phase: PrismSyncPhase.paused),
Failed(:final error) =>
PrismSyncSnapshot(phase: PrismSyncPhase.failed, error: error),
Syncing(:final phase, :final completed, :final total) => PrismSyncSnapshot(
phase: phase == SyncPhase.pulling
? PrismSyncPhase.pulling
: PrismSyncPhase.pushing,
completed: completed,
total: total,
),
};
Any other engine — a queue, a REST client, a Firestore listener — maps onto the same six phases just as easily.
Values
- idle → const PrismSyncPhase
-
Nothing to do; everything is up to date.
- pushing → const PrismSyncPhase
-
Uploading local changes.
- pulling → const PrismSyncPhase
-
Downloading remote changes.
- offline → const PrismSyncPhase
-
Waiting for connectivity.
- failed → const PrismSyncPhase
-
The last attempt failed.
- paused → const PrismSyncPhase
-
Synchronisation is paused by the user.
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- index → int
-
A numeric identifier for the enumerated value.
no setterinherited
- name → String
-
Available on Enum, provided by the EnumName extension
The name of the enum value.no setter - runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Constants
-
values
→ const List<
PrismSyncPhase> - A constant List of the values in this enum, in order of their declaration.