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
- AsyncOperationMixin: For one-shot operations.
- StreamOperationMixin: For continuous streams.
Both mixins expose the same four runtime states via OperationState:
IdleOperation, LoadingOperation, SuccessOperation, and
ErrorOperation.
Classes
-
AllTransitions<
T> - All destinations available through an OperationState reference.
-
ErrorOperation<
T> - Represents a failed operation with error details. Can optionally retain cached data from a previous successful operation.
-
FromError<
T> - Destinations available through an ErrorOperation reference.
-
FromIdle<
T> - Destinations available through an IdleOperation reference.
-
FromLoading<
T> - Destinations available through a LoadingOperation reference.
-
FromSuccess<
T> - Destinations available through a SuccessOperation reference.
-
IdleOperation<
T> - Represents an idle operation that is ready but not currently loading. Can optionally carry cached data from a previous successful operation.
-
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.
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.
Extensions
-
ErrorTransitions
on ErrorOperation<
T> - Transitions from error to loading, idle, or success.
-
IdleTransitions
on IdleOperation<
T> - Transitions from idle to loading, success, or error.
-
LoadingTransitions
on LoadingOperation<
T> - Transitions from loading to idle, success, or error.
-
OperationTransitions
on OperationState<
T> - Exposes all destinations when the receiver is an OperationState.
-
SuccessTransitions
on SuccessOperation<
T> - Transitions from success to loading, idle, or error.