Skip to content
pubscout

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.

WASM-ready
$ flutter pub add command_it
Source repository

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.

  • yx_state

    A state management library for Dart and Flutter applications.

  • cached_query

    Library for caching, background fetching, and managing server state in Dart and Flutter.

  • refena

    A state management and dependency injection library inspired by Riverpod and async_redux.

Works with

Packages commonly used together with command_it: ones it builds on, ones built on it, and its own family.