Skip to content
pubscout

typed_sql

0.1.14, released 9 weeks ago by google.dev

Type-safe SQL queries and schema definitions using code generation.

$ flutter pub add typed_sql
Source repository

What it does

Provides a type-safe API for interacting with SQL databases like SQLite and Postgres in Dart. It uses build_runner code generation to map tables and rows, allowing you to build queries using a fluent API with strong null-safety guarantees.

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

Use it when

  • You want compile-time type safety for your SQL queries in Dart
  • You are targeting SQLite or Postgres and want a fluent query builder
  • You prefer generating Dart classes from schema definitions

Skip it when

  • You need support for databases other than SQLite and Postgres
  • You prefer writing raw SQL strings without code generation
  • You need a production-ready and fully stable database ORM

Strengths

  • Strict type and null-safety matching database constraints
  • Fluent extension-method based query builder
  • Supports SQLite and Postgres natively

Weaknesses

  • Under active development with potential breaking changes
  • Requires setup with build_runner code generation
  • Limited database backend support

Setup

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

Requires adding typed_sql and dev:build_runner, then executing 'dart run build_runner build' to generate model part-files.

abstract final class Bookstore extends Schema {
  Table<Author> get authors;
  Table<Book> get books;
}

@PrimaryKey(['authorId'])
abstract final class Author extends Row {
  @AutoIncrement()
  int get authorId;

  @Unique.field()
  String get name;
}

Alternatives

Packages that do the same job and could replace typed_sql.

  • drift

    Drift is a more mature and widely used reactive SQLite database library for Dart and Flutter with robust tooling.

  • sqflite

    Sqflite gives you direct, lightweight control over raw SQLite queries without code generation overhead.

Works with

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