AgentSkillsCN

oref

本指南旨在帮助您更好地使用 Oref Flutter 信号/状态管理库及其 DevTools/分析工具。无论是在解答有关 Oref 安装、信号/计算属性/副作用的创建、异步数据、响应式集合、SignalBuilder 的使用、分析器 Lint 规则、DevTools 扩展的配置与使用,还是在排查 Oref 行为相关问题时,均可参考本指南。

SKILL.md
--- frontmatter
name: oref
description: Guidance for using the Oref Flutter signals/state management library and its DevTools/analyzer tooling. Use when answering questions about installing Oref, creating signals/computed/effects, async data, reactive collections, SignalBuilder usage, analyzer lints, DevTools extension setup/usage, or troubleshooting Oref behavior.

Oref

Based on the Oref docs and repository examples. Use BuildContext-bound APIs inside widget builds when possible.

Preferences

  • Match the user's language.
  • Prefer concise, runnable snippets over long explanations.
  • Use signal(context, ...)/computed(context, ...)/effect(context, ...) inside build.
  • Use null context only outside widgets, and keep the dispose handle.
  • Use SignalBuilder to scope rebuilds to small subtrees.
  • Use batch() for multi-step updates or collection mutations.
  • Avoid writing to signals inside computed getters.
  • Call hooks unconditionally at the top level of a build scope.

Core

TopicDescriptionReference
Quick StartInstall + minimal signal/computed/effect usagequick-start
Reactivity CoreSignals, computed, writableComputed, effects, batch, untrack, SignalBuildercore-api
Hooks & LifecycleHook ordering rules, onMounted/onUnmounted, cleanuphooks-lifecycle
Async DatauseAsyncData lifecycle and renderingasync-data
CollectionsReactiveList/Map/Set patternscollections

Tooling

TopicDescriptionReference
Analyzer LintsPlugin setup + lint cataloganalyzer-lints
DevToolsExtension setup + runtime notesdevtools
TroubleshootingCommon pitfalls and fixestroubleshooting

Quick Reference

Minimal widget

dart
import 'package:flutter/material.dart';
import 'package:oref/oref.dart';

class Counter extends StatelessWidget {
  const Counter({super.key});

  @override
  Widget build(BuildContext context) {
    final count = signal(context, 0);
    final doubled = computed(context, (_) => count() * 2);

    return Column(
      children: [
        Text('Count: ${count()} / ${doubled()}'),
        TextButton(onPressed: () => count.set(count() + 1), child: const Text('Add')),
      ],
    );
  }
}

Key imports

dart
import 'package:oref/oref.dart';

Response workflow

  1. Identify the question type and open the matching reference.
  2. Provide the smallest snippet that answers the question.
  3. Ask for missing context only if required (Flutter version, target platform, existing code).
  4. Avoid guessing versions; read the user's pubspec.yaml or ask them to confirm.