FakeSyncAdapter class

Scriptable SyncAdapter for tests and demos.

Succeeds for every task by default. Every batch it receives is recorded in batches so tests can assert what was sent and in which order.

final adapter = FakeSyncAdapter()
  ..failNext(1, error: 'HTTP 503');      // first batch fails
Implemented types

Constructors

FakeSyncAdapter({FakeBatchHandler? handler, Duration latency = Duration.zero})
Creates a FakeSyncAdapter. Succeeds for every task unless a handler is given.

Properties

batches → List<List<SyncTask>>
Every batch received, in order. Tasks are copies taken at send time.
final
handler ↔ FakeBatchHandler
Fallback handler used when no scripted response is queued.
getter/setter pair
hashCode → int
The hash code for this object.
no setterinherited
latency ↔ Duration
Optional artificial latency for each batch.
getter/setter pair
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
sentTaskIds → List<String>
TaskIds sent so far, flattened, in order.
no setter
sentTasks → List<SyncTask>
All tasks sent so far, flattened.
no setter

Methods

enqueueResponse(FakeBatchHandler response) → void
Queues a one-off handler for the next batch.
failNext(int count, {String error = 'Simulated failure', bool permanent = false}) → void
Fails the next count batches entirely with error.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
syncBatch(List<SyncTask> tasks) → Future<SyncResult>
Syncs a batch of tasks to the server.
override
throwNext(int count, Object error) → void
Makes the next count batches throw error.
toString() → String
A string representation of this object.
inherited

Operators

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