command_it는 `ValueListenable`과 명령 디자인 패턴을 기반으로 한 상태 관리 솔루션으로, Flutter 앱에서 상태 변경을 깔끔하고 반응형 방식으로 처리할 수 있도록 제공합니다. 원래는 flutter_command로 알려져 있었으며, 비동기 작업 및 상태 업데이트를 관리하는 구조적인 접근 방식을 제공합니다. 이 패키지는 명령 내에 동작을 캡슐화함으로써 관심사의 분리를 촉진하여 코드를 더 테스트 가능하고 유지보수하기 쉽게 만듭니다. Flutter의 반응형 프레임워크와 원활하게 통합되며 모든 주요 플랫폼을 지원합니다.
Command pattern for Flutter - wrap functions as observable objects with automatic state management
Commands replace async methods with reactive alternatives. Wrap your functions, get automatic loading states, error handling, and UI integration. No manual state tracking, no try/catch everywhere.
Call them like functions. React to their state. Simple as that.
Part of flutter_it — A construction set of independent packages. command_it works standalone or combines with watch_it for reactive UI updates.
Why Commands?
🎯 Declarative — Wrap functions, get observable execution state automatically
⚡ Automatic State — isRunning, value, errors tracked without manual code
🛡️ Smart Error Handling — Route errors globally/locally with filters
Chain commands together with the pipeToCommand() extension. When the source completes successfully, it automatically triggers the target command:
// Trigger refresh after save completes
saveCommand.pipeToCommand(refreshCommand);
// Transform result before passing to target
userIdCommand.pipeToCommand(fetchUserCommand, transform: (id) => UserRequest(id));
// Pipe from any ValueListenable - track execution state changes
longRunningCommand.isRunning.pipeToCommand(spinnerStateCommand);
The pipeToCommand() extension works on any ValueListenable, including commands, isRunning, results, or plain ValueNotifier. Returns a ListenableSubscription for manual cancellation if needed.
⚠️ Warning: Circular pipes (A→B→A) cause infinite loops. Ensure your pipe graph is acyclic.
Ecosystem Integration
Built on listen_it — Commands are ValueListenable objects, so they work with all listen_it operators (map, debounce, where, etc.).
// Register with get_it
di.registerLazySingleton(() => TodoManager());
// Use commands in your managersclassTodoManager{
final loadTodosCommand = Command.createAsyncNoParam<List<Todo>>(
() => api.fetchTodos(),
[],
);
// Debounce search with listen_it operatorsfinal searchCommand = Command.createSync<String, String>((s) => s, '');
TodoManager() {
searchCommand.debounce(Duration(milliseconds: 500)).listen((term, _) {
loadTodosCommand.run();
});
}
}
Want more? Combine with other flutter_it packages:
listen_it — Required dependency. ValueListenable operators and reactive collections.
Optional: watch_it — State management. Watch commands reactively without builders: watchValue((m) => m.loadCommand).
Optional: get_it — Service locator for dependency injection. Access managers with commands from anywhere: di<TodoManager>().
💡 flutter_it is a construction set — command_it works standalone. Add watch_it and get_it when you need reactive UI and dependency injection.
This package ships an Agent Skill for AI coding assistants
(Claude Code, Cursor, GitHub Copilot, Codex, Gemini CLI and others) in skills/command-it-expert/.
It teaches them the critical rules, common patterns and anti-patterns of command_it.
Install it into your project with the official Dart skills tool:
dart run skills@ get
For the ecosystem-wide skills (architecture guidance, feed/data-source patterns, overview)
and the skills of the other flutter_it packages run: