QueuedBackend class

Wraps any FeedbackBackend with transparent offline-queue support.

  • When the device is offline, submit silently enqueues the entry.
  • When the device is online but the backend throws, the entry is enqueued instead of propagating the exception.
  • Call flushQueue after connectivity is restored to drain the queue.
final backend = QueuedBackend(
  backend: WebhookBackend(url: 'https://example.com/feedback'),
  queue: SharedPrefsQueue(),
  onQueued: (entry) {
    ScaffoldMessenger.of(context).showSnackBar(
      const SnackBar(content: Text('Saved offline. Will send when connected.')),
    );
  },
);
Implemented types

Constructors

QueuedBackend({required FeedbackBackend backend, required FeedbackQueue queue, ConnectivityService? connectivity, void onQueued(FeedbackEntry entry)?})
Creates a QueuedBackend.

Properties

hashCode int
The hash code for this object.
no setterinherited
lastSubmitWasQueued bool
true if the most recent submit call enqueued rather than delivered.
no setter
onQueued → void Function(FeedbackEntry entry)?
Optional callback fired whenever an entry is added to the queue instead of being delivered immediately.
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

dispose() → void
Releases resources held by this backend (e.g. an HTTP client).
override
flushQueue() Future<int>
Attempts to deliver all queued entries via the underlying backend.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
submit(FeedbackEntry entry) Future<void>
Submits entry to the underlying backend, or enqueues it if offline or if the backend throws.
override
toString() String
A string representation of this object.
inherited

Operators

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