smithery/pluginagentmarketplace

custom-plugin-flutter-skill-database

1800+ lines of database architecture mastery - SQLite, Hive, ObjectBox, Firestore, encryption, offline-first, sync with production-ready code examples.

Installation

$ npx skills add smithery/pluginagentmarketplace --skill custom-plugin-flutter-skill-database

Similar popular skills

Related neighbors and high-traction skills in the same topics — useful to compare before installing.

Also in this package

Other skills from smithery/pluginagentmarketplace · top by installs.

npx skills add smithery/pluginagentmarketplace

Browse all from smithery/pluginagentmarketplace

More details

Agent compatibility

Declared targets from SKILL.md / docs. Unmarked agents are not listed — the skill may still install via the CLI.

Claude Code Not declared
Cursor Not declared
Codex Not declared
GitHub Copilot Not declared
Windsurf Not declared
Gemini CLI Not declared
Cline Not declared
OpenCode Not declared

Package contents

Files included with this skill beyond the listing page.

  • skill md SKILL.md 4,590 B
  • docs SUMMARY.md 195 B

History

  1. First recorded snapshot · 0 installs

SKILL.md

custom-plugin-flutter: Database & Storage Skill

Quick Start - Hive Storage

// Define model
@HiveType(typeId: 0)
class User {
  @HiveField(0)
  final String id;
  @HiveField(1)
  final String name;

  User({required this.id, required this.name});
}

// Use Hive
Future<void> main() async {
  await Hive.initFlutter();
  Hive.registerAdapter(UserAdapter());
  runApp(MyApp());
}

// Save
final box = await Hive.openBox<User>('users');
await box.put('user1', User(id: '1', name: 'John'));

// Retrieve
final user = box.get('user1');

// Watch changes
box.listenable().addListener(() {
  print('Box changed!');
});

1. Storage Solutions

SharedPreferences (Simple):

final prefs = await SharedPreferences.getInstance();
await prefs.setString('username', 'john');
final username = prefs.getString('username');

Hive (Flexible):

@HiveType(typeId: 0)
class Product {
  @HiveField(0)
  final String id;
  @HiveField(1)
  final String name;
  @HiveField(2)
  final double price;

  Product({required this.id, required this.name, required this.price});
}

final box = await Hive.openBox<Product>('products');
await box.add(Product(id: '1', name: 'Widget', price: 9.99));
final products = box.values.toList();

SQLite (Relational):

final database = await openDatabase(
  'app.db',
  onCreate: (db, version) async {
    await db.execute('''
      CREATE TABLE users (
        id TEXT PRIMARY KEY,
        name TEXT NOT NULL,
        email TEXT NOT NULL
      )
    ''');
  },
);

// Insert
await database.insert('users', {
  'id': '1',
  'name': 'John',
  'email': '[email protected]',
});

// Query
final users = await database.query('users');

2. Encryption

import 'package:encrypt/encrypt.dart' as encrypt;

class SecureStorage {
  late final encrypt.Key _key;
  late final encrypt.IV _iv;

  SecureStorage() {
    _key = encrypt.Key.fromSecureRandom(32);
    _iv = encrypt.IV.fromSecureRandom(16);
  }

  String encrypt(String plaintext) {
    final encrypter = encrypt.Encrypter(encrypt.AES(_key));
    return encrypter.encrypt(plaintext, iv: _iv).base64;
  }

  String decrypt(String ciphertext) {
    final encrypter = encrypt.Encrypter(encrypt.AES(_key));
    return encrypter.decrypt64(ciphertext, iv: _iv);
  }
}

3. Migrations

final database = await openDatabase(
  'app.db',
  version: 2,
  onCreate: (db, version) async {
    await db.execute('CREATE TABLE users (id TEXT PRIMARY KEY, name TEXT)');
  },
  onUpgrade: (db, oldVersion, newVersion) async {
    if (oldVersion < 2) {
      await db.execute('ALTER TABLE users ADD COLUMN email TEXT');
    }
  },
);

4. Offline-First Sync

class SyncEngine {
  final LocalDatabase local;
  final RemoteAPI remote;
  final _queue = <SyncOperation>[];

  Future<void> sync() async {
    // Upload pending changes
    for (final op in _queue) {
      try {
        await _uploadOperation(op);
        _queue.remove(op);
      } catch (e) {
        // Retry later
      }
    }

    // Download remote changes
    try {
      final remoteData = await remote.getUpdates();
      await _mergeRemoteData(remoteData);
    } catch (e) {
      // Continue with local data
    }
  }

  Future<void> _mergeRemoteData(dynamic remoteData) async {
    for (final item in remoteData) {
      final local = await this.local.getItem(item['id']);
      if (local == null || item['updatedAt'] > local['updatedAt']) {
        await this.local.upsert(item);
      }
    }
  }
}

5. Firestore

class FirestoreRepository {
  final firestore = FirebaseFirestore.instance;

  Future<User?> getUser(String id) async {
    final doc = await firestore.collection('users').doc(id).get();
    return doc.exists ? User.fromJson(doc.data()!) : null;
  }

  Stream<List<User>> watchUsers() {
    return firestore
        .collection('users')
        .orderBy('createdAt')
        .snapshots()
        .map((snap) => snap.docs
            .map((doc) => User.fromJson(doc.data()))
            .toList());
  }

  Future<void> createUser(User user) async {
    await firestore.collection('users').doc(user.id).set(
      user.toJson(),
      SetOptions(merge: true),
    );
  }
}

Master database design for scalable Flutter applications.