Skip to main content
ORM support is available via the following package (currently in a beta release):

drift_sqlite_async | Dart package

This package enables using the Drift persistence library (ORM) with the PowerSync Dart/Flutter SDK. The Drift integration gives Flutter developers the flexibility to write queries in either Dart or SQL. Importantly, it supports propagating change notifications from the PowerSync side to Drift, which is necessary for streaming queries. The use of this package is recommended for Flutter developers who already know Drift, or specifically want the benefits of an ORM for their PowerSync projects.

Example implementation

An example project which showcases setting up and using Drift with PowerSync is available here:

GitHub - powersync.dart/demos/supabase-todolist-drift

Troubleshooting: Watch Streams with Local-Only Tables

When using local-only tables with a viewName that differs from the table name, Drift’s watch() streams may not receive update notifications. This happens because PowerSync sends notifications using the internal table name (e.g., local_items), but Drift is listening for the view name (e.g., items). Example problem:
// PowerSync schema with viewName override
Table.localOnly(
  'local_items',    // Internal table name
  [...],
  viewName: 'items', // User-facing view name
)
Solution: Use transformTableUpdates to map internal names to view names:
import 'package:drift/drift.dart' show TableUpdate;

final connection = SqliteAsyncDriftConnection(
  powerSyncDatabase,
  transformTableUpdates: (notification) {
    return notification.tables.map((tableName) {
      if (tableName.startsWith('local_')) {
        // Convert local_items → items
        return TableUpdate(tableName.substring(6));
      }
      return TableUpdate(tableName);
    }).toSet();
  },
);

final db = AppDatabase(connection);
This ensures Drift receives notifications with the expected view names, allowing watch streams to work correctly.

Support for Other Flutter ORMs

Other ORMs for Flutter, like Floor, are not currently supported. It is technically possible to open a separate connection to the same database file using Floor but there are two big caveats to that: Write locks Every write transaction (or write statement) will lock the database for other writes for the duration of the transaction. While transactions are typically short, if multiple happen to run at the same time they may fail with a SQLITE_BUSY or similar error. External modifications Often, ORMs only detect notifications made using the same library. In order to support streaming queries, PowerSync requires the ORM to allow external modifications to trigger the same change notifications, meaning streaming queries are unlikely to work out-of-the-box.