add method
void
add()
Adds an edge from the _offlineAdapterKey
to the key
for save/delete
and stores header/param metadata. Also stores callbacks.
Implementation
void add() {
// DO NOT proceed if operation is in queue
if (!adapter.offlineOperations.contains(this)) {
adapter.log(label, 'offline/add ${label.requestId}');
adapter.db.execute(
'INSERT INTO _offline_operations (label, request, timestamp, headers, body, key) VALUES (?, ?, ?, ?, ?, ?)',
[
label.toString(),
httpRequest,
timestamp,
jsonEncode(headers),
body,
key
]);
// keep callbacks in memory
adapter.ref.read(_offlineCallbackProvider)[label.requestId] ??=
(null, null);
adapter.ref.read(_offlineCallbackProvider)[label.requestId] =
(onSuccess, onError);
}
}