> ## Documentation Index
> Fetch the complete documentation index at: https://docs.powersync.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Dart/Flutter ORM Support

> Use the Drift ORM with the PowerSync Flutter SDK via drift_sqlite_async.

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

<Card title="drift_sqlite_async | Dart package" icon="dart-lang" href="https://pub.dev/packages/drift_sqlite_async" horizontal />

This package enables using the [Drift](https://pub.dev/packages/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:

<Card title="GitHub - powersync.dart/demos/supabase-todolist-drift" icon="github" href="https://github.com/powersync-ja/powersync.dart/tree/master/demos/supabase-todolist-drift" horizontal />

## 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:**

```dart theme={null}
// 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:

```dart theme={null}
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](https://pinchbv.github.io/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.
