Flutter ORM Support

ORM support is available via the following package (currently in an alpha release):

This package enables using the Drift persistence library (ORM) with the PowerSync 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 of using the drift_sqlite_async package with PowerSync is available here.

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.

Further reading

See Using ORMs with PowerSync on our blog.

Last updated