flutter-drift
安装方式
先用 Prompt 核对来源与依赖。也可下载安装包。
用 AI 助手安装
复制提示词,让助手先核对固定版本和依赖。
查看 Prompt收起 Prompt
先检查当前 Agent 是否已安装 SkillPI Skill Finder。如果尚未安装,请按官方仓库的说明安装并启用:https://github.com/Findskills/skillpi。然后使用 Skill Finder 打开此 SkillPI 详情页并定位 "flutter-drift":https://skillpi.com/zh/skills/deepskill-dddae6bd0d6d052e1d58c32dcc2708099f374e9462c99f256787c85ae6834c8b。安装前核对上游来源和版本:https://github.com/MADTeacher/mad-agents-skills。来源不一致时停止并说明差异。核对通过后,用 Skill Finder 安装目标 Skill,并报告安装路径和来源版本。
来源与配置
github.com
配置方式待核实
请查看原始来源中的适用工具、依赖和权限要求。
安装实测待补充
实现、修复、审查、迁移、测试或调试 Flutter 应用中的 Drift 持久化,使用 SQLite、drift_flutter、类型安全的 Dart 查询、生成的表、响应式 Stream UI、写入与事务、模式迁移、Web 资源与隔离共享。用于处理本地数据库、CRUD、schemaVersion、build_runner 与 drift_dev 的迁移与测试相关任务,涵盖移动、Web 与桌面环境。
介绍来源: third_party · MADTeacher · 1.1 参考来源
SkillPi 解读
- 能完成的任务
- 翻译待完成,请参阅来源文档。
- 适合谁
- 来源文档未说明。
- 输入和输出
- 来源文档未说明。
- 软件、账号及付费要求
- 来源文档未说明。
- 限制与区别
- 来源文档未说明。
- 实测状态
- 未测试
文件浏览
Frontmatter
name: flutter-drift
description: Implement, fix, review, migrate, test, or debug Drift persistence in Flutter apps using SQLite, drift_flutter, type-safe Dart queries, generated tables, StreamBuilder or Riverpod StreamProvider UI, write operations, transactions, schema migrations, web assets, isolate sharing, and local database testing. Use when a Flutter task mentions drift, local database storage, SQLite, reactive database streams, CRUD, schemaVersion, build_runner, drift_dev make-migrations, migration tests, or Flutter-specific database setup across mobile, web, or desktop.
metadata:
author: Stanislav [MADTeacher] Chernyshev
version: "1.1"Flutter Drift
Use this skill to add or repair Drift-based local persistence in Flutter apps. The skill is an operating workflow: inspect the target app first, choose only the relevant reference files, implement with current Drift APIs, and validate generated code.
Core Workflow
- Inspect the app before editing:
- Check
pubspec.yaml, existing database files,build.yaml, state management package, target platforms, and tests. - Prefer the app's current architecture and naming over the examples in this skill.
- Check
- Add or verify dependencies with package commands instead of hardcoding versions:
dart pub add drift drift_flutter path_provider dev:drift_dev dev:build_runner- Add
providerorflutter_riverpodonly when the app already uses it or the user asks for that integration.
- Create or update the database entry point:
- Define tables in Dart or
.driftfiles. - Add the tables to
@DriftDatabase. - Open Flutter databases with
driftDatabasefrompackage:drift_flutter/drift_flutter.dartunless the project needs a custom executor.
- Define tables in Dart or
- Keep Drift calls scoped to the database object:
- Use
database.select(database.todoItems),database.into(database.todoItems),database.update(database.todoItems), anddatabase.delete(database.todoItems)from widgets, services, and repositories. - Use bare
select(todoItems)only insideGeneratedDatabasesubclasses orDatabaseAccessorclasses where the methods and table getters are in scope.
- Use
- Generate code after changing Drift declarations:
- Run
dart run build_runner build. - Treat generator errors as blockers, not optional cleanup.
- Run
- For schema changes in an existing app, use Drift's guided migration workflow:
- Configure
drift_devdatabases inbuild.yaml. - Run
dart run drift_dev make-migrationsbefore and after schema changes as needed. - Bump
schemaVersion, write generated step-by-step migrations, and run generated migration tests.
- Configure
- Validate before finishing:
- Run
dart formaton edited Dart files. - Run
flutter analyzeordart analyzefor the package. - Run targeted tests, including generated migration tests when migrations changed.
- Run
Resource Routing
- Read references/setup.md when adding Drift, opening a database, configuring web support, or sharing a database across isolates.
- Read references/tables.md when defining tables, columns, defaults, keys, indexes, constraints, generated columns, or strict tables.
- Read references/queries.md when implementing selects, filters, sorting, pagination, joins, aggregations, subqueries, custom columns, or unions.
- Read references/writes.md when implementing inserts, updates, deletes, upserts, companions, transactions, or batch operations.
- Read references/streams.md when implementing reactive Drift streams, StreamBuilder, StreamProvider, custom select streams, table update listeners, or manual stream invalidation.
- Read references/migrations.md when
schemaVersion, existing user data,build.yaml,make-migrations, generated schema files, or migration tests are involved. - Read references/flutter-ui.md when wiring Drift data into Flutter widgets with Provider, Riverpod, StreamBuilder, search, filtering, pagination, or user-facing loading and error states.
Required API Rules
- Do not call
select(database.table)as a top-level function from a widget. Usedatabase.select(database.table)outside database classes. - Do not use
watch(...),todoUpdates(...), ornotifyTableUpdates(...). UsecustomSelect(...).watch(),tableUpdates(...), andnotifyUpdates(...). - Do not call
delete(table).go(id). Add awhereclause and then callgo(), or use generated table extension helpers if the project already uses them. - Do not use
batch.updateAll(...)or pass raw ids tobatch.delete(...). Usebatch.update(..., where: ...),batch.delete(...)with an insertable row, orbatch.deleteWhere(...). - Do not mix Provider and Riverpod APIs.
Provider.of<AppDatabase>(context)belongs toprovider;Provider<AppDatabase>((ref) { ... })andAsyncValue.when(...)belong to Riverpod. - Do not bump
schemaVersionwithout a migration plan for existing databases. - Do not rely on raw SQLite writes when UI streams must update. Use Drift write APIs or call
notifyUpdateswith explicitTableUpdatemetadata.
Fallbacks
- If package downloads are blocked, update source files and leave exact
dart pub addorflutter pub addcommands for the user, then state that dependency resolution was not validated. - If a project cannot run
build_runner, do not hand-write generated*.g.dartfiles. Fix source declarations and report the generator blocker. - If migration state is unclear, stop before changing
schemaVersion; ask for the current released schema history or database files. - If web support is required but
sqlite3.wasmanddrift_worker.jsare missing, add the code path and explicitly report the required web assets.
Validation Checklist
pubspec.yamlcontains Drift runtime and generator dependencies.- Database files have valid
partdirectives, table declarations,@DriftDatabase, constructor, andschemaVersion. - All query and write examples are scoped to the correct database/accessor context.
- Generated code was rebuilt with
build_runner. - Flutter UI examples handle loading, empty, error, and data states without treating
AsyncValueas aList. - Migrations changed only with generated schema snapshots, step-by-step migration code, and tests.
flutter analyzeordart analyzepasses for the edited package, or any remaining analyzer failure is reported with the blocker.
当前收录版本
1.1
安全与评测信息
质量评测
满分100 · 来自 SkillPi LAB 实验室的评测报告。
亮点
- 针对 Flutter Drift 持久化的专业解决方案,覆盖完整开发工作流
- 提供从依赖管理到迁移测试的端到端指导
- 包含实用的 API 规则和验证清单
待提升项
-
触发词覆盖范围较广 原报告严重程度:轻微
描述包含了大量相关技术术语,虽然全面但可能与其他 Flutter 数据库技能存在重叠
改进建议:可考虑进一步细化触发条件,突出 Drift-specific 的独特功能点
亮点
- 覆盖了 Drift 生态系统的核心概念和常用技术栈
待提升项
-
description 内容重复 原报告严重程度:轻微
description 同时在 frontmatter 和 skill_body 中出现,存在冗余
改进建议:建议移除 skill_body 中的重复 description,保持信息一致性
亮点
- 结构清晰,包含完整的工作流、资源路由、API 规则和验证清单
- 文档组织良好,便于开发者按步骤执行
亮点
- 提供了具体的命令示例和错误处理指导
- 覆盖了迁移、Web 支持、隔离共享等复杂场景
- 包含完整的验证检查清单确保执行质量
取前四项原始分值的算术平均,四舍五入取整。可通过收录报告核对各项评分与说明,运行记录需单独查证。
正文静态检测
100 / 100 · skillpi-20261123-no-r3-v1
正文未命中当前规则。
分数仅反映正文中的规则命中,供使用前参考。附件与运行行为不在此评分范围内。
权限与使用前检查
根据当前主文档自动整理,命中内容可能是示例或防护说明;不是实际权限声明,也未覆盖附件、外部依赖或运行行为。
未从主文档识别到上述常见操作,不能据此判断无需权限或没有风险。
安全评级与访问范围
safe · 静态证据核验,不代表运行安全保证。
来源文档未说明。
使用前请由宿主核对并授权实际文件读写、外部服务和联网目的地;本站的核验不会授予任何运行权限。
用户讨论
还没有已核实的点评。