database_skill

This skill helps manage local data persistence and secrets securely across Drift, SharedPreferences, and flutter_secure_storage with clear patterns.
  • Shell

3

GitHub Stars

1

Bundled Files

2 months ago

Catalog Refreshed

3 months ago

First Indexed

Readme & install

Copy the install command, review bundled files from the catalogue, and read any extended description pulled from the listing source.

Installation

Preview and clipboard use veilstrat where the catalogue uses aiagentskills.

npx veilstrat add skill yelmuratoff/agent_sync --skill database

  • SKILL.md3.4 KB

Overview

This skill provides best-practice patterns for persisting app data in Flutter: structured local SQL via Drift, lightweight typed preferences for small non-sensitive settings, and secure secret storage with flutter_secure_storage. It focuses on folder layout, DAO patterns, and small adapters that keep code testable and maintainable. The goal is safe, queryable caching and clear separation between sensitive and non-sensitive data.

How this skill works

Drift is used for centralized, queryable tables and feature-scoped DAOs that handle batch operations and transactions. SharedPreferences is wrapped in typed DAOs to expose strongly-typed entries and avoid direct global access. flutter_secure_storage is wrapped behind a small interface so secrets (tokens, credentials) are read/written via a mockable adapter for tests.

When to use it

  • Use Drift for large lists, JSON blobs, offline cache, and any data you need to query or join.
  • Use SharedPreferences for small, non-sensitive user settings and feature flags.
  • Use flutter_secure_storage for tokens, credentials, and any sensitive secrets.
  • Wrap platform APIs behind interfaces to enable mocking and unit testing.
  • Prefer DAOs per feature to keep persistence logic localized and maintainable.

Best practices

  • Place Drift tables centrally and DAOs in feature datasource folders for a feature-first layout.
  • Perform cache replace operations in a single batch/transaction: delete old rows then insert new ones.
  • Regenerate Drift code with the project’s build_runner command after schema changes.
  • Never store secrets in SharedPreferences; always use secure storage for sensitive data.
  • Expose typed preference entries (get/set) instead of passing SharedPreferences.getInstance around.

Example use cases

  • Cache API responses as JSON rows in a Drift table with a cacheKey and timestamp, then read by cacheKey.
  • Store a 'hasSeenOnboarding' boolean as a typed preference entry and access via .value/.setValue().
  • Persist OAuth access and refresh tokens using a secure storage adapter implementing ISecureStorage.
  • Replace cached search results by deleting entries for a cacheKey and inserting new JSON in one batch.
  • Unit test token logic by injecting a mock ISecureStorage adapter instead of platform storage.

FAQ

A small interface makes the storage mockable for unit tests and decouples app code from the implementation.

When should I prefer Drift over SharedPreferences?

Use Drift when you need structured queries, large lists, offline caching, or data relationships; SharedPreferences is only for simple flags and small settings.

Built by
VeilStrat
AI signals for GTM teams
© 2026 VeilStrat. All rights reserved.All systems operational
database skill by yelmuratoff/agent_sync | VeilStrat