flutter-databases
Installation
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.
- Yes: Use
- Is the data a large, structured, relational dataset requiring fast inserts/queries?
- Yes: Use On-device relational databases (
sqfliteordrift).
- Yes: Use On-device relational databases (
- Is the data a large, unstructured/non-relational dataset?
- Yes: Use On-device non-relational databases (
hive_ceorisar_community).
- Yes: Use On-device non-relational databases (
- 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_imageto store images on the file system.
- Yes: Use
- Is the data too large for
shared_preferencesbut doesn't require querying?- Yes: Use direct File System I/O.