flutter-working-with-databases

Implements offline-first Flutter data layers using SQLite, repositories, and synchronization services.

1|Updated Apr 30, 2026
One-click install
npx skills add https://github.com/Wishtohear/bucket-water-oms --skill flutter-working-with-databases-wishtohear
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: flutter-working-with-databases
Source: https://github.com/Wishtohear/bucket-water-oms/tree/main/bucket-water-oms-admin-mobile/skills/flutter-working-with-databases
Command: npx skills add https://github.com/Wishtohear/bucket-water-oms --skill flutter-working-with-databases-wishtohear

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires sqflite, path, shared_preferences, cached_network_image.

What problem does it solve? Flutter apps that need to store, query, and synchronize structured data locally often end up with scattered persistence logic, SQL injection risks, and broken offline behavior. This Skill provides a structured architecture for building a reliable data layer with SQLite and offline-first synchronization. ## Core Features & Use Cases - Layered Data Architecture: Separates Repositories (single source of truth, business logic, domain models) from Services (stateless wrappers around SQLite and HTTP APIs). - Offline-First Synchronization: Streams cached local data immediately, fetches remote updates, and queues failed writes with a synchronized: false flag for background retry. - Safe SQLite Practices: Uses sqflite with path, table/column constants, AUTOINCREMENT primary keys, and whereArgs to prevent SQL injection. - Use Case: A delivery driver app must record signed orders while offline. The repository writes to SQLite immediately, then syncs to the backend API when connectivity returns. ## Quick Start Implement an offline-first repository with SQLite persistence for my Flutter app's order data using sqflite.

Frequently Asked Questions about flutter-working-with-databases

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I implement offline-first data sync in Flutter?▼

Build a repository that yields cached SQLite data immediately, fetches fresh data from the API service, updates the local database, and yields the new data. For writes, save locally first and flag records as unsynchronized if the network request fails.

How to use SQLite in a Flutter app with sqflite?▼

Add the sqflite and path packages, define table and column name constants, and create tables in the onCreate callback of openDatabase. Always use whereArgs with parameterized queries like where: 'id = ?' to prevent SQL injection.

What is the difference between repositories and services in Flutter architecture?▼

Repositories act as the single source of truth, holding business logic, caching, and mapping raw models to domain models. Services are stateless wrappers around data sources like SQLite or HTTP clients and perform no business logic.

Which Flutter package should I use for local data storage?▼

Use shared_preferences for small key-value settings, sqflite or drift for large relational datasets, and hive_ce or isar_community for non-relational data. For remote images, cached_network_image handles file-system caching automatically.

How do I prevent SQL injection in sqflite queries?▼

Never interpolate values directly into SQL strings. Pass values through the whereArgs parameter, for example where: 'id = ?' with whereArgs: [id], so the database engine safely binds the parameters.