Flutter ORM Support (Alpha)
An introduction to using ORMs with PowerSync is available on our blog here.
ORM support is available via the following package (currently in an alpha release):
drift_sqlite_async | Dart package
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 project which showcases setting up and using Drift with PowerSync is available here:
powersync.dart/demos/supabase-todolist-drift
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.
Was this page helpful?