LibraryActive

Drift

A reactive persistence library for Flutter and Dart, built on SQLite.

Open source page ↗

Field note

What it does

drift is a reactive persistence library for Flutter and Dart, built on SQLite. It provides type-safe SQL queries, migrations, and reactive streams.

Capabilities

Available capabilities

Tags

Tags

Ways to use it

Ways to use it

sdk

Dart / drift

sdk

Dart / drift_flutter

other

Not filed / Not filed

Product features

Product features

Companions

Companion classes for partial updates and inserts with Value.absent() support.

Compiled queries

Generate methods from SQL files for type-safe queries.

Custom migration strategy

Use onCreate callbacks to insert data on first app start.

Custom select

Support for raw SQL queries with table tracking.

@DriftDatabase annotation

Annotate a class to define the database and trigger code generation.

Framework integrations

Works with Flutter StreamBuilder and Riverpod StreamProvider.

Inserts

Insert rows using companions, with support for auto-increment and default values.

ISO 8601 string storage

Stores DateTime in ISO 8601 text format with UTC offset handling.

Joins

Support for inner and left outer joins.

Log statements

Enable logStatements to print SQL statements executed.

Manager API

Provides a manager-based query API.

Manual update notifications

Ability to manually mark tables as updated.

Migration guides

Guides for migrating between datetime storage modes.

Migrations

Manage schema migrations and custom migration strategies.

Modular code generation

Generate standalone library files to avoid name conflicts.

Pre-populated database

Include a pre-populated database asset in your app.

Query builder

Core query builder for building queries.

Reactive streams

Provides reactive queries that update automatically.

Schema migrations

Supports advanced schema migrations with testing tools.

Schema version getter

Required getter for migrations.

Selectable interface

Provides get(), getSingle(), getSingleOrNull() and matching watch() methods.

SQL dialect configuration

Configure drift_dev to support PostgreSQL via build.yaml.

SQL expressions

Use Companion.custom to apply SQL expressions during updates.

Subqueries

Ability to use subqueries in select statements.

Table definition in Dart

Define tables using Dart classes extending Table.

Type-safe API

Dart API for writing SQL queries with type safety.

Type-safe SQL

Provides type-safe query building and result mapping.

Unix timestamp storage

Stores DateTime as SQL INTEGER containing unix timestamp in seconds.

Updates and deletes

Use generated classes to update or delete rows with optional where clauses.

Upserts

Insert or update on conflict using insertOnConflictUpdate.