A comprehensive Dart and Flutter library ecosystem for declarative SQLite schema management and database operations with real-time synchronization capabilities.
Declarative SQLite provides a fluent, type-safe API for defining database schemas and managing data with automatic migrations, streaming queries, and built-in synchronization features. The ecosystem consists of multiple packages that work together seamlessly to provide a robust database solution for Dart and Flutter applications.
The foundation of the ecosystem. It provides all the core functionality for schema definition, data manipulation, and synchronization.
Key Features:
- Declarative Schema: Define your database schema using a fluent, easy-to-read builder API.
- Automatic Migrations: The library automatically detects schema changes and generates/applies the necessary migration scripts.
- Type-Safe Queries: Build complex SQL queries with type safety and autocompletion.
- Streaming Queries: Create reactive queries that automatically emit new results when underlying data changes.
- Conflict-Free Sync: Built-in support for data synchronization using a Hybrid Logical Clock (HLC) to ensure conflict-free, last-write-wins data merging.
- Graceful Error Handling: Robust constraint violation handling during bulk operations with configurable strategies.
- File Management: Integrated support for attaching and managing files linked to database records.
Provides Flutter-specific widgets and utilities to easily integrate declarative_sqlite into your Flutter applications.
Key Features:
DatabaseProvider: AnInheritedWidgetthat provides easy access to your database instance throughout the widget tree.QueryListView: A reactiveListViewthat listens to a streaming query and automatically rebuilds itself when the data changes.
A build-time code generator that creates boilerplate code for you, enhancing productivity and reducing errors.
Key Features:
- Typed Record Classes: Automatically generates typed getters and setters for your
DbRecordclasses based on your schema. - Factory Registration: Generates code to automatically register your typed record factories, simplifying database setup.
A complete Flutter application showcasing the features of the declarative_sqlite ecosystem in action. Use it as a reference and a starting point for your own projects.
To get started, add the necessary packages to your pubspec.yaml:
dependencies:
flutter:
sdk: flutter
declarative_sqlite: ^1.3.0
declarative_sqlite_flutter: ^1.3.0
dev_dependencies:
build_runner: ^2.4.10
declarative_sqlite_generator: ^1.3.0For a detailed guide, please refer to our official documentation.
┌─────────────────────────────────────┐
│ Flutter Application │
├─────────────────────────────────────┤
│ > declarative_sqlite_flutter │
| --- |
│ • DatabaseProvider │
│ • QueryListView │
├─────────────────────────────────────┤
│ > declarative_sqlite │
| --- |
│ • Schema Definition & Migration │
│ • CRUD & Query Builders │
│ • Streaming Queries │
│ • HLC-based Sync Management │
│ • File Management │
├─────────────────────────────────────┤
│ > declarative_sqlite_generator │
| --- |
│ • DbRecord Code Generation │
├─────────────────────────────────────┤
│ SQLite Database │
└─────────────────────────────────────┘
Contributions are welcome! If you'd like to contribute, please follow these steps:
- Fork the repository.
- Create a new feature branch (
git checkout -b feature/your-feature). - Make your changes and add tests.
- Ensure all tests pass (
dart testorflutter test). - Submit a pull request.
This project is licensed under the MIT License - see the LICENSE file for details.