command_it
9.5.2, released 2 months ago by flutter-it.dev
Wrap sync and async functions as callable Command objects with reactive state.
What it does
Wraps synchronous or asynchronous functions into callable Command objects. It automatically exposes execution state like running, errors, and results as ValueListenables for easy reactive UI integration.
AI-written summary of version 9.5.2, based on the package's README and metadata. Report an inaccuracy
Use it when
- You want automatic loading states and error handling for async operations without boilerplate try/catch blocks.
- You want to prevent parallel executions of the same action natively.
- You want a lightweight alternative to heavier state management frameworks.
Skip it when
- You need complex event-driven BLoC patterns or heavily structured architectural models.
- You rely entirely on non-ValueListenable state providers.
Strengths
- Eliminates manual try/catch and loading state boilerplate.
- Built-in protection against parallel execution.
- Integrates seamlessly with ValueListenable and watch_it.
Weaknesses
- Requires learning the Command pattern paradigm.
- Circular pipes can cause infinite loops if not carefully constructed.
Setup
- Kind
- Flutter widgets
- Effort
- Low
- Code generation
- No
- Direct dependencies
- 3
Requires listen_it as a dependency. No native configuration or code generation needed.
final incrementCommand = Command.createAsyncNoParam<String>(
() async => '1',
initialValue: '0',
);
ElevatedButton(
onPressed: incrementCommand.run,
child: Text('Increment'),
);Alternatives
Packages that do the same job and could replace command_it.
- result_command
A command pattern implementation for Dart and Flutter using result_dart.
58Compare - yx_state
A state management library for Dart and Flutter applications.
82Compare - cached_query
Library for caching, background fetching, and managing server state in Dart and Flutter.
90Compare - refena
A state management and dependency injection library inspired by Riverpod and async_redux.
87Compare
Works with
Packages commonly used together with command_it: ones it builds on, ones built on it, and its own family.
- stack_tracecommand_it depends on itProvides parsing, inspection, and readable formatting of Dart stack traces.
- quivercommand_it depends on itA set of utility libraries for Dart containing collections, async tools, and testing helpers.
- listen_itcommand_it depends on itValueListenable operators and reactive collections for Flutter and Dart
- watch_itSame familyState management powered by get_it to observe changes and rebuild widgets automatically.
- flutter_itBuilt on command_itRe-exports get_it, watch_it, command_it, and listen_it for a single import.