compose_state library

Classes

ApiState<T>
BatchingConfig
Configuration for notification batching behavior.
BuildEvent
Event representing a build operation for testing verification.
CircuitBreakerStrategy
Circuit breaker strategy to prevent cascading failures.
ComposeViewModel
DerivedState<T>
EnhancedStateBuilder<T>
Enhanced UI components with comprehensive error handling and testing support.
EqualityChecker<T>
A comprehensive equality checker that supports deep comparison with caching mechanisms for performance optimization.
Error<T>
ErrorContext
Context information for error handling operations.
ErrorContextBuilder
Utility class for creating error contexts.
ErrorHandlerConfig
Configuration for error handling behavior.
ErrorRecoveryStrategy
Interface for defining error recovery strategies.
ErrorStats
Statistics for error tracking and monitoring.
FallbackStrategy
Fallback strategy that provides default values.
GenericTypeHandler
Handles generic type preservation and validation across serialization boundaries.
GenericTypeInfo
Contains information about a generic type.
GlobalErrorBoundary
Global error boundary for catching unhandled state errors.
HistoryState<T>
InMemoryStorage<T>
Loading<T>
MockApiState<T>
Mock implementation for API states
MockState<T>
A mock implementation of ObservableState for testing purposes.
MultiStateBuilder
Multi-state builder that can listen to multiple states efficiently.
MutableState<T>
NotificationBatcher
A notification batcher that reduces unnecessary widget rebuilds by batching multiple state changes together.
ObservableState<T>
Base interface for all observable state types in the compose_state package.
OfflinePersistableState<T>
OptimizedState<T>
Performance-optimized state implementation that uses deep equality checking and notification batching to reduce unnecessary rebuilds.
OptimizedStateBuilder<T>
Enhanced StateBuilder that works optimally with batched notifications and provides additional performance optimizations.
PersistableState<T>
RecoveryResult<T>
Result of an error recovery attempt.
ResetStrategy
Reset strategy that resets state to initial values.
RetryStrategy
Retry strategy with exponential backoff.
SequenceVerification<T>
Verification that checks the sequence of state changes.
Serializable
SerializationSchema
Defines serialization validation rules and migration paths.
SerializationValidator
Validates serialization operations to ensure type safety during persistence.
Serializer<T>
Interface for custom serializers.
SharedPreferencesStorage<T>
SignalState<T>
StateBuilder<T>
Enhanced StateBuilder with automatic disposal, error boundaries, and performance optimizations.
StateButton<T>
Enhanced state-driven button with loading and error states.
StateChange<T>
Represents a single state change within a transaction.
StateChangeEntry<T>
Represents a single state change entry.
StateChangeEvent<T>
Represents a state change event for testing purposes
StateChangeRecord<T>
Records a state change for testing purposes.
StateChangeTracker
Comprehensive state change tracking and verification system.
StateChangeVerification
Abstract base class for state change verifications.
StateDebugger<T>
StateErrorHandler
Comprehensive error handler for state management operations.
StateEvent
Events that occur in the state registry for monitoring and debugging.
StateFormField<T>
Enhanced state-driven form field with comprehensive error handling.
StateLifecycleManager
Manages the lifecycle of state objects with automatic disposal and weak reference tracking.
StateLifecycleStats
Statistics about state lifecycle management.
StateListView<T>
Enhanced state-driven list view with error handling and performance optimization.
StateManager
Centralized manager for state lifecycle and memory management.
StateMatchers
Utility functions for testing state properties.
StateMemoryStats
Statistics about state memory usage.
StateMetadata
Metadata associated with a registered state.
StateRegistry
Global registry for state tracking and memory monitoring.
StateRegistryStats
Statistics about the state registry.
StateSnapshot<T>
Represents a snapshot of state at a specific point in time.
StateStatistics
Statistics for an individual state.
StateTestUtils
Comprehensive testing utilities for the compose_state package.
StateTrackingStatistics
Statistics about state tracking.
StateTransaction
Encapsulates multiple state changes that should be applied atomically.
Storage<T>
StreamState<T>
Success<T>
TestBuilderStats
Comprehensive statistics for test verification.
TestConfiguration
Configuration for test mode behavior.
TestStateBuilder<T>
Test-friendly version of StateBuilder with enhanced tracking and control capabilities.
TestStateBuilderState<T>
TestStateChangeEvent<T>
Event representing a state change for testing verification.
TestStateListener<T>
A test listener that tracks state changes and call counts.
TestStateScenario
A test scenario for integration testing with multiple states.
TransactionManager
Manages atomic multi-state updates through transactions.
TypeInfo
Contains metadata about a type for validation purposes.
TypeToken<T>
Represents a type token for preserving generic type information.
TypeValidator
A comprehensive runtime type validation system for state management.
UiState<T>
UiStateBuilder<T>
ValidationSchema
Defines validation rules for a specific type or structure.
ValueVerification<T>
Verification that checks if a state value matches an expected value.
ViewModelScope

Enums

BatchingStrategy
Strategy for batching notifications.
CircuitState
States of a circuit breaker.
StateEventType
Types of events that can occur in the state registry.
TransactionStatus
Represents the current status of a transaction.

Mixins

DisposableState
A mixin that provides automatic resource cleanup capabilities for state objects.
ErrorBoundary
Mixin that provides error boundary functionality to state classes.
NetworkErrorBoundary
Mixin for states that need to handle network/API errors.
Persistable
PersistenceErrorBoundary
Mixin for states that need to handle persistence errors.
SerializationErrorBoundary
Mixin for states that need to handle serialization errors.
TransactionalStateMixin<T>
Mixin that adds transaction support to state implementations.
ValidationErrorBoundary
Mixin for states that need to handle validation errors.
ValidationMixin<T>
Mixin that provides validation capabilities to state implementations.

Extensions

IterableExtension on Iterable<T>
Extension to add firstOrNull to Iterable.
TransactionalStateExtension on ObservableState<T>
Extension methods for working with transactions on any ObservableState.
ValidationExtensions on ValidationMixin<T>
Extension methods for common validation scenarios.

Properties

defaultEqualityChecker EqualityChecker
Default equality checker instance for general use.
final
globalNotificationBatcher NotificationBatcher
Global notification batcher instance.
final

Functions

apiStateOf<T>({StateErrorHandler? errorHandler}) ApiState<T>
buildEnhancedState<T>(ObservableState<T> state, Widget builder(BuildContext, T), {Widget errorBuilder(BuildContext, StateException)?, Widget loadingBuilder(BuildContext)?, EqualityChecker<T>? equalityChecker, bool enableOptimizations = true, bool enableAutoDisposal = true, bool enableErrorBoundary = true, StateErrorHandler? errorHandler, String? builderKey, bool isTestMode = false, TestConfiguration? testConfig}) Widget
Factory functions for creating enhanced UI components. Creates an enhanced state builder with sensible defaults.
buildMultiState(List<ObservableState> states, Widget builder(BuildContext, List), {bool enableOptimizations = true}) Widget
Convenience function to create a multi-state builder.
buildOptimizedState<T>(ObservableState<T> state, Widget builder(BuildContext, T), {EqualityChecker<T>? equalityChecker, bool enableOptimizations = true}) Widget
Convenience function to create an optimized state builder.
buildState<T>(ObservableState<T> state, Widget builder(BuildContext, T), {Widget errorBuilder(BuildContext, StateException)?, Widget loadingBuilder(BuildContext)?, EqualityChecker<T>? equalityChecker, bool enableOptimizations = true, bool enableAutoDisposal = true, bool enableErrorBoundary = true, StateErrorHandler? errorHandler, String? builderKey}) Widget
Convenience function to create a StateBuilder with common configurations.
buildStateButton<T>(ObservableState<T> state, bool isEnabled(T), bool isLoading(T), bool hasError(T), Widget child, {VoidCallback? onPressed, Widget? loadingWidget, Widget? errorWidget, ButtonStyle? style, StateErrorHandler? errorHandler}) Widget
Creates a state-driven button with loading and error states.
buildStateFormField<T>(ObservableState<T> state, String valueToString(T), T parseValue(String), {String? validator(T?)?, String? label, String? hint, bool enabled = true, StateErrorHandler? errorHandler, InputDecoration? decoration, TextInputType? keyboardType, bool obscureText = false, int? maxLines = 1}) Widget
Creates a state-driven form field with validation.
buildStateListView<T>(ObservableState<List<T>> listState, Widget itemBuilder(BuildContext, T, int), {Widget emptyBuilder(BuildContext)?, Widget loadingBuilder(BuildContext)?, Widget errorBuilder(BuildContext, StateException)?, EqualityChecker<List<T>>? equalityChecker, bool enableOptimizations = true, StateErrorHandler? errorHandler, ScrollController? controller, ScrollPhysics? physics, bool shrinkWrap = false, EdgeInsetsGeometry? padding}) Widget
Creates a state-driven list view with error handling.
buildTestState<T>(ObservableState<T> state, Widget builder(BuildContext, T), {Widget errorBuilder(BuildContext, StateException)?, EqualityChecker<T>? equalityChecker, bool enableAutoRebuild = true, bool enableChangeTracking = true, String? testKey, StateChangeTracker? changeTracker}) Widget
Convenience function to create a TestStateBuilder.
createEqualityChecker<T>({EqualityFunction<T>? customEquals, HashFunction<T>? customHashCode, int maxCacheSize = 1000, bool enableCaching = true}) EqualityChecker<T>
Creates a specialized equality checker for a specific type.
createNotificationBatcher({BatchingStrategy strategy = BatchingStrategy.frame, Duration delay = const Duration(milliseconds: 16), int maxBatchSize = 100, bool enableFrameAlignment = true}) NotificationBatcher
Creates a notification batcher with custom configuration.
createStateTracker() StateChangeTracker
Factory function for creating a state change tracker.
debouncedStateOf<T>(T initialValue, {Set<String>? tags, Map<String, dynamic>? metadata, EqualityFunction<T>? customEquals, HashFunction<T>? customHashCode, Duration delay = const Duration(milliseconds: 50)}) OptimizedState<T>
Creates an optimized state with debounced notifications.
debuggerStateOf<T>(ObservableState<T> state, String name) StateDebugger<T>
derivedStateOf<T>(T computation(), {List<ObservableState>? dependencies}) DerivedState<T>
historyStateOf<T>(T initialValue, {Set<String>? tags, Map<String, dynamic>? metadata, EqualityChecker<T>? equalityChecker, StateErrorHandler? errorHandler}) HistoryState<T>
immediateStateOf<T>(T initialValue, {Set<String>? tags, Map<String, dynamic>? metadata, EqualityFunction<T>? customEquals, HashFunction<T>? customHashCode}) OptimizedState<T>
Creates an optimized state with immediate notifications (no batching).
mockApiStateOf<T>() MockApiState<T>
mockStateOf<T>(T initialValue) MockState<T>
Factory functions for creating mock states
mutableStateOf<T>(T initialValue, {Set<String>? tags, Map<String, dynamic>? metadata, EqualityChecker<T>? equalityChecker, StateErrorHandler? errorHandler}) MutableState<T>
optimizedStateOf<T>(T initialValue, {Set<String>? tags, Map<String, dynamic>? metadata, EqualityFunction<T>? customEquals, HashFunction<T>? customHashCode, BatchingStrategy batchingStrategy = BatchingStrategy.frame, bool enableCaching = true}) OptimizedState<T>
Creates an optimized mutable state with performance enhancements.
persistableState<T>(T initialValue, {required String fieldName, required Persistable persistable, Map<String, Serializable Function(String)>? typeRegistry, bool enableHistory = false, StateErrorHandler? errorHandler}) PersistableState<T>
signalStateOf<T>(T initialValue) SignalState<T>
streamStateOf<T>(Stream<T> stream, T initialValue) StreamState<T>

Typedefs

EqualityFunction<T> = bool Function(T a, T b)
Function signature for custom equality comparisons.
HashFunction<T> = int Function(T value)
Function signature for custom hash code generation.
TransactionCallback = void Function(StateTransaction transaction)
Callback function for transaction events.

Exceptions / Errors

StateConsistencyException
Exception thrown when state consistency is violated.
StateException
Base class for all state-related exceptions.
StatePersistenceException
Exception thrown when state persistence operations fail.
StateSerializationException
Exception thrown when state serialization operations fail.
StateValidationException
Exception thrown when state validation fails.