Skip to content
pubscout

drift_dev

2.35.3, released 12 days ago by simonbinder.eu

Generates Dart database code from Drift table definitions as a dev‑dependency.

$ flutter pub add drift_dev
Source repository

What it does

Drift_dev provides the build‑runner generator that reads your Drift table classes and emits type‑safe Dart code for queries, data classes, and schema verification. It also offers utilities for schema validation and migration support.

AI-written summary of version 2.35.2, based on the package's README and metadata. Report an inaccuracy

Use it when

  • You are using the drift package to work with SQLite and want compile‑time generated query helpers.
  • You need automatic handling of SQL naming conflicts and schema verification during development.

Skip it when

  • You only need runtime database access without code generation.
  • You are not using drift or prefer a pure‑SQL approach.

Strengths

  • Seamless integration with build_runner and the drift ecosystem
  • Supports latest analyzer, cli_util, and build versions
  • Handles reserved Dart keywords and SQL column name conflicts automatically

Weaknesses

  • Requires a build step, adding compile time to the workflow
  • Only a dev‑dependency; no runtime functionality on its own

Setup

Kind
Pure Dart
Effort
Medium
Code generation
Yes (build_runner)
Direct dependencies
25

Add drift_dev to dev_dependencies, ensure build_runner is present, then run `flutter pub run build_runner build` or watch mode.

```dart
import 'package:drift/drift.dart';
import 'package:drift_dev/moor_generator.dart'; // generated part

part 'app_database.g.dart';

@DriftDatabase(tables: [Users])
class AppDatabase extends _$AppDatabase {
  AppDatabase() : super(_openConnection());

  @override
  int get schemaVersion => 1;
}

// Run `flutter pub run build_runner build` to generate app_database.g.dart
```

Alternatives

Packages that do the same job and could replace drift_dev.

Works with

Packages commonly used together with drift_dev: ones it builds on, ones built on it, and its own family.