/madteacher:flutter-driftfrom madteacher
Complete guide for using drift database library in Flutter applications. Use when building Flutter apps that need local SQLite database storage with type-safe queries, reactive streams, migrations, and efficient CRUD operations. Includes setup with drift_flutter package, StreamBuilder integration, Provider/Riverpod patterns, and Flutter-specific database management for mobile, web, and desktop platforms.
Ships in madteacher. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
Comprehensive guide for using drift database library in Flutter applications.
Flutter Drift skill provides complete guidance for implementing persistent local storage in Flutter apps using the drift library. Drift is a reactive persistence library for Flutter built on SQLite, offering type-safe queries, auto-updating streams, schema migrations, and cross-platform support.
Add dependencies to pubspec.yaml:
dependencies:
drift: ^2.30.0
drift_flutter: ^0.2.8
path_provider: ^2.1.5
dev_dependencies:
drift_dev: ^2.30.0
build_runner: ^2.10.4
Define database:
@DriftDatabase(tables: [TodoItems])
class AppDatabase extends _$AppDatabase {
AppDatabase([QueryExecutor? e])
: super(
e ??
driftDatabase(
name: 'app_db',
native: const DriftNativeOptions(
databaseDirectory: getApplicationSupportDirectory,
),
web: DriftWebOptions(
sqlite3Wasm: Uri.parse('sqlite3.wasm'),
driftWorker: Uri.parse('drift_worker.js'),
),
),
);
@override
int get schemaVersion => 1;
}
Run code generator:
dart run build_runner build
See detailed documentation for each topic:
class TodoList extends StatelessWidget {
@override
Widget build(BuildContext context) {
final database = Provider.of<AppDatabase>(context);
return StreamBuilder<List<TodoItem>>(
stream: select(database.todoItems).watch(),
builder: (context, snapshot) {
final todos = snapshot.data ?? [];
return ListView.builder(
itemCount: todos.length,
itemBuilder: (context, index) {
final todo = todos[index];
return ListTile(
title: Text(todo.title),
trailing: Checkbox(
value: todo.isCompleted,
onChanged: (value) {
database.update(database.todoItems).replace(
TodoItem(
id: todo.id,
title: todo.title,
isCompleted: value ?? false,
),
);
},
),
);
},
);
},
);
}
}
Future<void> showAddTodoDialog(BuildContext context) async {
final controller = TextEditingController();
final database = Provider.of<AppDatabase>(context);
await showDialog(
context: context,
builder: (context) {
return AlertDialog(
title: const Text('Add Todo'),
content: TextField(
controller: controller,
decoration: const InputDecoration(labelText: 'Title'),
),
actions: [
TextButton(
onPressed: () => Navigator.pop(context),
child: const Text('Cancel'),
),
TextButton(
onPressed: () async {
if (controller.text.isNotEmpty) {
await database.into(database.todoItems).insert(
TodoItemsCompanion.insert(title: controller.text),
);
if (context.mounted) {
Navigator.pop(context);
}
}
},
child: const Text('Add'),
),
],
);
},
);
controller.dispose();
}
final databaseProvider = Provider<AppDatabase>((ref) {
final database = AppDatabase();
ref.onDispose(database.close);
return database;
});
@override
MigrationStrategy get migration {
return MigrationStrategy(
onUpgrade: stepByStep(
from1To2: (m, schema) async {
await m.addColumn(schema.todoItems, schema.todoItems.dueDate);
},
),
);
}
Uses drift_flutter with getApplicationSupportDirectory.
Place sqlite3.wasm and drift_worker.js in web/ folder.
AppDatabase.defaults(): super(
driftDatabase(
name: 'app_db',
native: DriftNativeOptions(
shareAcrossIsolates: true,
),
),
);
Use in-memory database for tests:
AppDatabase createTestDatabase() {
return AppDatabase(NativeDatabase.memory());
}
dart run build_runner clean
dart run build_runner build --delete-conflicting-outputs
dart run drift_dev schema validate
dart run drift_dev make-migrations
Ensure operations go through drift APIs, not raw SQLite.
What SKILL.md sets; muted values are Claude Code's defaults
npx claudepluginhub ulpi-io/plugin-marketplace --plugin madteacher11 skills in this plugin
/agents-md-generatorCreate or update minimal AGENTS.md files in the repository root and nested module directories using progressive disclosure. Works across heterogeneous projects without assuming any fixed agent folder structure./dart-driftComplete guide for using drift database library in Dart applications (CLI, server-side, non-Flutter). Use when building Dart apps that need local SQLite database storage or PostgreSQL connection with type-safe queries, reactive streams, migrations, and efficient CRUD operations. Includes setup with sqlite3 package, PostgreSQL support with drift_postgres, connection pooling, and server-side patterns./flutter-adaptive-uiOther plugins' skills for the same job