result_command
2.2.0, released a year ago by flutterando.com.br
A command pattern implementation for Dart and Flutter using result_dart.
What it does
Encapsulates actions into commands with built-in state management for idle, running, success, failure, and cancellation states. It integrates with result_dart to handle operations and supports listening via ValueListenableBuilder or listeners.
AI-written summary of version 2.2.0, based on the package's README and metadata. Report an inaccuracy
Use it when
- You want to encapsulate asynchronous actions and manage their execution lifecycle.
- You need built-in state tracking (running, success, failure, cancelled) for UI buttons or components.
- You use result_dart and want structured command handling.
Skip it when
- You prefer global state architectures like BLoC or Riverpod for complex application-wide state.
- Your project does not use the result_dart package.
Strengths
- Clean encapsulation of command lifecycle and state.
- Built-in support for cancellation and timeouts.
- Cached success and failure states to prevent unnecessary UI flickering.
Weaknesses
- Tied specifically to the result_dart package.
- Not a full architectural framework on its own for complex global states.
Setup
- Kind
- Flutter widgets
- Effort
- Low
- Code generation
- No
- Direct dependencies
- 1
Add result_command and result_dart to pubspec.yaml dependencies.
final fetchGreetingCommand = Command0<String>(
() async {
await Future.delayed(Duration(seconds: 2));
return Success('Hello, World!');
},
);
fetchGreetingCommand.execute();Alternatives
Packages that do the same job and could replace result_command.
- command_it
Wrap sync and async functions as callable Command objects with reactive state.
76Compare - bloc
A Dart library for implementing the BLoC pattern with Cubits and Blocs.
92Compare - flutter_bloc
Flutter widgets to easily integrate blocs and cubits for state management.
86Compare - tanstack_query
Flutter implementation of TanStack Query for caching, synchronizing, and updating server state.
71Compare
Works with
Packages commonly used together with result_command: ones it builds on, ones built on it, and its own family.