brick_offline_first
4.0.2, released a year ago by an unverified publisher
Unified offline‑first repository that syncs SQLite with remote providers.
What it does
It routes data fetching through a memory cache, a local SQLite provider, and a remote provider (REST/GraphQL). Policies let you control when to read/write locally or remotely and it queues failed remote writes for later sync.
AI-written summary of version 4.0.2, based on the package's README and metadata. Report an inaccuracy
Use it when
- You need reliable offline support with automatic sync to a backend
- You want a single API for CRUD that works both online and offline
- Your app already uses Brick for other domains
Skip it when
- The app only needs simple network calls without local persistence
- You prefer a lightweight solution without code generation
- You are not using SQLite or Brick elsewhere
Strengths
- Automatic offline‑first sync and policy control
- Supports memory cache, SQLite queue for failed requests
- Integrates with Brick codegen for models and providers
Weaknesses
- Adds build_runner step and code‑gen complexity
- Tied to Brick ecosystem, not a generic solution
- May be overkill for small apps
Setup
- Kind
- Pure Dart
- Effort
- Medium
- Code generation
- No
- Direct dependencies
- 9
Add brick_core, brick_sqlite and other deps, run `flutter pub run build_runner build`, configure local and remote providers in your repository.
import 'package:brick_offline_first/brick_offline_first.dart';
class PersonRepository extends OfflineFirstRepository with DeleteAllMixin {
PersonRepository({required super.localProvider, required super.remoteProvider});
Future<Person?> getPerson(int id) => get<Person>(id);
}
// Usage
final repo = PersonRepository(
localProvider: SqliteProvider(...),
remoteProvider: RestProvider(...),
);
final person = await repo.getPerson(1);Alternatives
Packages that do the same job and could replace brick_offline_first.
- local_value
An abstraction layer to persist data to the local file system, shared preferences, or secure storage.
43Compare
Works with
Packages commonly used together with brick_offline_first: ones it builds on, ones built on it, and its own family.
- dart_stylebrick_offline_first depends on itProvides an API and CLI to format Dart source code automatically.
- loggingbrick_offline_first depends on itProvides configurable logging with levels and stream listeners for Dart apps.
- sqflite_commonbrick_offline_first depends on itDart wrapper on SQLite providing the common API for sqflite and desktop FFI implementations.
- brick_corebrick_offline_first depends on itInterfaces and shared helpers for models, adapters, and repositories in Brick.
- brick_offline_first_with_supabaseBuilt on brick_offline_firstRoutes data fetching through local providers before Supabase with offline caching.