ConflictPolicy class sealed

ConflictPolicy is the preferred API over the bare ConflictResolver typedef (which is still supported for back-compat). The typed form documents the four common cases as named constants and provides a single point of extensibility for custom merge logic via ConflictPolicy.custom.

All four built-in variants are exposed as static fields on the sealed class so the call site reads like a value:

final sync = MySyncProvider(
  conflictPolicy: ConflictPolicy.lww,        // server wins
  // or
  conflictPolicy: ConflictPolicy.clientWins,  // local wins
  // or
  conflictPolicy: ConflictPolicy.custom(
    MergeStrategies.preferLocalColumns(['updated_by']),
  ),
);

LwwConflictResolver.instance and CustomConflictResolver.wrap(resolver) are retained as back-compat shims and return the same ConflictResolver functions as before.

Implementers

Constructors

ConflictPolicy.custom(ConflictResolver resolver)
User-provided merge callback. Use when the built-in policies do not fit. The MergeStrategies helpers (preferLocalColumns, preferRemoteColumns, maxOf) plug in here.
factory

Properties

hashCode int
The hash code for this object.
no setterinherited
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
resolve(Map<String, Object?> localRow, Map<String, Object?> remotePayload) Map<String, Object?>
Resolves a conflict between a local row (already in the local DB) and a remote payload (just received from the server). Returns the merged row to apply.
toString() String
A string representation of this object.
inherited

Operators

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

Constants

clientWins → const ConflictPolicy
Local wins on every collision. Inverse of lww / serverWins: the merged row keeps every local value, and remote fills in only the columns the local row does not have.
lww → const ConflictPolicy
Server wins on every collision (the default for d_rocket since v0.5). Synonym for serverWins.
serverWins → const ConflictPolicy
Server wins on every collision. Synonym for lww — the two constants return the same instance; pick whichever name reads better at the call site.