flutter_operations library

Type-safe async & stream state management for Flutter powered by sealed classes, exhaustive pattern matching, and cached data. No more juggling isLoading, error, and data fields.

Exported mixins

Both mixins expose the same four runtime states via OperationState: IdleOperation, LoadingOperation, SuccessOperation, and ErrorOperation.

Classes

ErrorOperation<T>
Represents a failed operation with error details. Can optionally retain cached data from a previous successful operation.
IdleOperation<T>
LoadingOperation<T>
Represents an operation that is currently in progress. Can optionally carry cached data from a previous successful operation.
OperationState<T>
Represents the state of an asynchronous operation.
SuccessOperation<T>
Represents a successfully completed operation with associated data. The data is guaranteed to be non-null in this state.

Mixins

AsyncOperationMixin<T, K extends StatefulWidget>
A mixin that adds asynchronous state management to a StatefulWidget.
StreamOperationMixin<T, K extends StatefulWidget>
A mixin that adds stream-based state management to a StatefulWidget.