SerializableRequest class

A serializable representation of an HTTP request that can be persisted to disk and reconstructed later.

Unlike QueuedRequest which holds a closure, SerializableRequest stores the raw HTTP details so the request can be replayed from storage.

final request = SerializableRequest(
  id: 'update_profile_123',
  method: 'POST',
  url: 'https://api.example.com/profile',
  headers: {'Authorization': 'Bearer token'},
  body: '{"name": "John"}',
  cacheKey: 'profile',
  maxRetries: 3,
);
Annotations

Constructors

SerializableRequest({required String id, required String method, required String url, Map<String, String> headers = const {}, String? body, String? cacheKey, int maxRetries = 3, DateTime? enqueuedAt})
const
SerializableRequest.fromJson(Map<String, dynamic> json)
Deserialize from JSON map.
factory

Properties

body String?
Request body (JSON string for POST/PUT/PATCH).
final
cacheKey String?
Optional cache key for the result.
final
enqueuedAt DateTime?
When this request was enqueued.
final
hashCode int
The hash code for this object.
no setterinherited
headers Map<String, String>
HTTP headers.
final
id String
Unique identifier.
final
maxRetries int
Maximum number of retries.
final
method String
HTTP method (GET, POST, PUT, DELETE, PATCH).
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
url String
Full URL including query parameters.
final

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toJson() Map<String, dynamic>
Serialize to JSON map.
toString() String
A string representation of this object.
override

Operators

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