flutter-working-with-databases

Installation
Summary

SQLite and offline-first data layer architecture for Flutter apps with structured local persistence.

  • Separates data layer into stateless Services (raw data wrappers) and business-logic Repositories (single source of truth per domain entity)
  • Implements offline-first synchronization: reads yield cached local data immediately then fetch remote updates; writes save locally first, then attempt API sync with background queue fallback
  • Covers SQLite setup with safe parameterized queries, Domain Model transformation, and caching strategies for key-value, large datasets, and images
  • Includes complete code examples for Repository streams, Database Service implementation, and step-by-step workflows for adding new data features
SKILL.md

Architecting the Data Layer

Contents

Core Architecture

Construct the data layer as the Single Source of Truth (SSOT) for all application data. In an MVVM architecture, the data layer represents the Model. Never update application data outside of this layer.

Separate the data layer into two distinct components: Repositories and Services.

Repositories

  • Act as the SSOT for a specific domain entity.
  • Contain business logic for data mutation, polling, caching, and offline synchronization.
  • Transform raw data models (API/DB models) into Domain Models (clean data classes containing only what the UI needs).
Related skills
Installs
8.4K
Repository
flutter/skills
GitHub Stars
1.9K
First Seen
Mar 13, 2026