Drift

Drift is a reactive persistence library for Flutter and Dart, built on top of SQLite.

Sponsors

Drift is proudly Sponsored by Stream 💙


Try the Flutter Chat Tutorial  💬

Features

Drift is

  • Flexible: Drift lets you write queries in both SQL and Dart, providing fluent apis for both languages. You can filter and order results or use joins to run queries on multiple tables. You can even use complex SQL features like WITH and WINDOW clauses.
  • 🔥 Feature rich: Drift has builtin support for transactions, schema migrations, complex filters and expressions, batched updates and joins. We even have a builtin IDE for SQL!
  • 📦 Modular: Thanks to builtin support for daos and imports in SQL files, drift helps you keep your database code simple.
  • 🛡️ Safe: Drift generates type-safe code based on your tables and queries. If you make a mistake in your queries, drift will find it at compile time and provide helpful and descriptive lints.
  • ⚡ Fast: Even though drift lets you write powerful queries, it can keep up with the performance of key-value stores. Drift is the only major persistence library with builtin threading support, allowing you to run database code across isolates with zero additional effort.
  • Reactive: Turn any SQL query into an auto-updating stream! This includes complex queries across many tables
  • ⚙️ Cross-Platform support: Drift works on Android, iOS, macOS, Windows, Linux and the web. This template is a Flutter todo app that works on all platforms
  • 🗡️ Battle tested and production ready: Drift is stable and well tested with a wide range of unit and integration tests. It powers production Flutter apps.

With drift, persistence on Flutter is fun!

To start using drift, read our detailed docs.

If you have any questions, feedback or ideas, feel free to create an issue. If you enjoy this project, I'd appreciate your 🌟 on GitHub.

Libraries

backends
Utility classes to implement custom database backends that work together with drift.
drift
extensions/geopoly
https://www.sqlite.org/geopoly.html The Geopoly Interface To The SQLite R*Tree Module
extensions/json1
Experimental bindings to the json1 sqlite extension.
extensions/native
High-level bindings to mathematical functions that are only available in a NativeDatabase.
internal/export_schema
internal/migrations
Contains tools for verifying migrations that don't depend on sqlparser and can thus be part of the core drift package.
internal/modular
Internal library used by generated code when drift's modular code generation is enabled.
internal/versioned_schema
Defines base classes to generate lightweight tables and views. This library is used by code generated via drift_dev schema steps to generate snapshots of every schema version of your database without much overhead.
isolate
Contains utils to run drift databases in a background isolate.
native
A drift database implementation built on package:sqlite3/.
remote
Library support for accessing remote databases.
sqlite_keywords
Provides utilities around sql keywords, like optional escaping etc.
wasm
Web support for drift.
web
A version of drift that runs on the web by using sql.js You manually need to include that library into your website to use the web version of drift. See the documentation for a more detailed instruction.
web/worker
Utility functions enabling the use of web workers to accelerate drift on the web.