What problem does it solve?
Riverpod mutations provide a clean way to model the lifecycle of an asynchronous UI action (idle, pending, success, error) without polluting the main state management logic, reducing boilerplate and improving UX feedback.
Core Features & Use Cases
- Mutation<T> instances to represent a single async task and its result type.
- Listen to mutation state with ref.watch to drive UI elements (loading spinners, error messages, success indicators).
- Support for MutationIdle, MutationPending, MutationSuccess, MutationError states and automatic resets.
- Keyed mutations for multiple concurrent actions and safe lifecycle boundaries around asynchronous work.
- Triggering via Mutation.run(ref, callback) to execute the action and return a value.
- Reset via Mutation.reset(ref) to restore Idle state when needed.
Quick Start
Create a Mutation<T> instance and call run with a callback that performs your async task.