markForSync method

void markForSync()

Marks this object for sync by setting sync_update_db flag to true. Must be called within a write transaction.

This is automatically called by writeWithSync(), but can be used manually:

realm.write(() {
  goal.title = "Updated";
  goal.markForSync(); // Mark for sync
});

Implementation

void markForSync() {
  if (!realm.isInTransaction) {
    throw RealmException(
      'markForSync must be called within a write transaction',
    );
  }

  try {
    // Try to set sync_update_db flag using dynamic access
    RealmObjectBase.set(this, 'sync_update_db', true);
  } catch (e) {
    // Silently ignore if sync_update_db doesn't exist
    // This allows models without the field to use the extension safely
  }
}