busic-state-management
SkillDev toolsBuSic状态管理规范。用于Riverpod codegen、Notifier编排、依赖注入和AutoDispose生命周期控制时快速查阅
Available today. Use it from your connected AI after setup.
No other account needed.
Connect ahel once, and every AI you use reads what you have installed.
Then ask your AI: use the busic-state-management skill
What this skill tells your AI
The instructions your AI receives, as published by glowled/busic in .agents/skills/busic-state-management/SKILL.md and read by ahel’s review.
何时使用
- 新增或重构
application/层 - 需要决定一个状态应该用
@riverpod还是手动 Provider - 遇到
autoDispose、异步生命周期、跨 feature 依赖相关问题
先看这些真源
Provider 选择
- 业务 Notifier 默认使用
@riverpod - Riverpod 3 下为
XxxNotifier显式声明@Riverpod(name: 'xxxNotifierProvider'),保持仓库既有 provider 命名 - 少量
StateProvider从package:flutter_riverpod/legacy.dart导入 - 全局注入、GoRouter、需要长期存活的 Repository 才使用手动 Provider
- Repository 依赖通常在 Notifier
build()中创建
Notifier 高频规则
- 异步初始化用
Future<T>,纯运行时状态用同步T - UI 调用公有方法,业务编排留在 Notifier
- 跨 feature 联动优先通过 Provider 或清晰的依赖注入完成
- 所有会跨异步间隙且还要读写
state/ref的方法,优先考虑ref.keepAlive()
UI 使用规则
build()里用ref.watch(...)- 回调和事件里用
ref.read(...) - 需要生命周期时用
ConsumerStatefulWidget
常见坑
autoDisposeprovider 在对话框、异步回调、跨帧操作中很容易被提前回收state = ...不要写在会抛异常的逻辑外面,避免半更新状态- 不要让 UI 直接拿 Repository 绕过 Notifier
相关 Skill
Signals
- GitHub stars
- 28
- Forks
- 8
- Last commit
- Sep 2026
Advanced
- Catalog kind
- skill
- Gateway key
busic-state-management- Source
- github.com/glowled/busic