flushAllPending method

Future<void> flushAllPending()

Implementation

Future<void> flushAllPending() async {
  // Copy keys to avoid mutation during iteration
  final patchIds = List<String>.from(_pendingPatchById.keys);
  for (final id in patchIds) {
    if ((_pendingPatchById[id] ?? {}).isEmpty) continue;
    if (_pendingDeleteIds.contains(id)) continue; // delete takes precedence
    if (_inFlightById[id] == true) continue;
    await _flush(id);
  }

  // Flush deletes last
  final deleteIds = List<String>.from(_pendingDeleteIds);
  for (final id in deleteIds) {
    if (_inFlightById[id] == true) continue;
    await _flushDelete(id);
  }
}