flutter-databases

Installation
Summary

MVVM-compliant data layer for Flutter with Repository pattern, stateless Services, and intelligent local caching strategies.

  • Guides selection of persistence technology (shared_preferences, sqflite, drift, hive_ce, isar_community, or file I/O) based on data type, size, and relational complexity
  • Implements Repository as single source of truth, isolating DatabaseService and ApiClient as private stateless dependencies
  • Provides complete code examples for domain models, SQLite operations, and offline-first sync patterns with parameterized queries to prevent SQL injection
  • Enforces architectural constraints: UI layer accesses only Repository, services remain stateless, database connection verified before operations
SKILL.md

flutter-data-layer-persistence

Goal

Architects and implements a robust, MVVM-compliant data layer in Flutter applications. Establishes a single source of truth using the Repository pattern, isolates external API and local database interactions into stateless Services, and implements optimal local caching strategies (e.g., SQLite via sqflite) based on data requirements. Assumes a pre-configured Flutter environment.

Decision Logic

Evaluate the user's data persistence requirements using the following decision tree to select the appropriate caching strategy:

  • Is the data small, simple key-value pairs (e.g., user preferences, theme settings)?
    • Yes: Use shared_preferences.
  • Is the data a large, structured, relational dataset requiring fast inserts/queries?
    • Yes: Use On-device relational databases (sqflite or drift).
  • Is the data a large, unstructured/non-relational dataset?
    • Yes: Use On-device non-relational databases (hive_ce or isar_community).
  • Is the data primarily API response caching?
    • Yes: Use a lightweight remote caching system or interceptors.
  • Is the data primarily images?
    • Yes: Use cached_network_image to store images on the file system.
  • Is the data too large for shared_preferences but doesn't require querying?
    • Yes: Use direct File System I/O.
Related skills
Installs
975
Repository
flutter/skills
GitHub Stars
1.9K
First Seen
Mar 4, 2026