Search packages, repositories and app categories

Package detailsv0.18.0

stormberry

A strongly-typed postgres ORM to provide easy bindings between your dart classes and postgres database.

AndroidiOSmacOSWindowsLinux
30-day downloads
258
Likes
138
Pub points
150

Install package

flutter pub add stormberry

Package Overview

Package selection guidance compiled from public package information, community data, and project usage.

Stormberry is a strongly-typed PostgreSQL ORM for Dart that simplifies the mapping between Dart classes and PostgreSQL database tables. It provides type-safe queries and schema management, reducing boilerplate and minimizing runtime errors. Designed for developers seeking reliable, maintainable database interactions in Flutter and Dart applications, Stormberry integrates seamlessly with PostgreSQL through clear, intuitive APIs. The package supports multiple platforms including Android, iOS, macOS, Windows, and Linux, making it ideal for cross-platform apps requiring robust backend data handling.

Use cases

  • Building cross-platform apps with PostgreSQL backends
  • Type-safe database operations in Flutter
  • Automating schema migrations
  • Reducing boilerplate in data layer code
  • Integrating PostgreSQL with Dart services

Key features

  • Strongly-typed entity mapping
  • Compile-time safety for queries
  • Support for platform-agnostic database access
  • Built-in migration utilities
  • Clean, readable query syntax

Suitable for

  • Dart/Flutter developers using PostgreSQL
  • Teams prioritizing type safety
  • Projects requiring scalable data layers
  • Backend services with structured data models
  • Applications needing consistent database schema management

Considerations

  • Requires PostgreSQL server setup
  • Limited to PostgreSQL (not other databases)
  • Learning curve for ORM concepts
  • Dependent on stable network connectivity in client apps
  • May require additional configuration for complex schemas

Original README

Original README snapshot from the linked source repository. Visit the repository for the latest content.

Stormberry


A strongly-typed postgres ORM to provide easy bindings between your dart classes and postgres database. It supports all kinds of relations without any complex configuration.


Quick Start

To get started, add stormberry as a dependency and build_runner as a dev dependency:

dart pub add stormberry
dart pub add build_runner --dev

In your code, specify an abstract class that should act as a table like this:

// This file is "model.dart"
import 'package:stormberry/stormberry.dart';

// Will be generated by stormberry
part 'model.schema.dart';

@Model()
abstract class User {
  @PrimaryKey()
  String get id;

  String get name;
}

In order to generate the database code, run the following command:

dart run build_runner build

Tip: You'll need to re-run code generation each time you are making changes to your models. During development, you can use watch to automatically watch your changes: dart pub run build_runner watch.

This will generate a .schema.dart file that you should add as a part to the original model file.


Before running your application, you have to migrate your database. To do this run:

dart run stormberry migrate

This will ask you for the connection details of your postgres database and then migrate the database schema by adding the users table.


To access your database from your application, create a Database instance and use the users repository like this:

void main() async {
  
  var db = Database(
    // connection parameters go here
  );
  
  // adds a user to the 'users' table
  await db.users.insertOne(UserInsertRequest(id: 'abc', name: 'Alex'));
  
  // finds a user by its 'id'
  var user = await db.users.queryUser('abc');
  
  assert(user.name == 'Alex');
}

Full Documentation

See the full documentation here or jump directly to the topic you are looking for:

Categories

Dependencies

Dependency list 12 items

Source repository

Projects using this package

No data available yet.