sync method

Future<void> sync()

Implementation

Future<void> sync() async {
  final operations = await syncQueue.getOperations();
  for (int i = 0; i < operations.length; i++) {
    final operation = operations[i];

    try {
      if (operation.entityType == 'project') {
        await _syncProjectOperation(operation);
      } else if (operation.entityType == 'task') {
        await _syncTaskOperation(operation);
      }
      await syncQueue.removeOperation(i); // Remove from queue if successful
    } catch (e) {
      print(
          'Sync failed for operation ${operation.type} on ${operation.entityType}: $e');
    }
  }
}