reactive_notifier library

A library for managing reactive state in Flutter applications.

This library provides classes and widgets to manage state reactively, ensuring a single instance of state per type and allowing for state changes to trigger UI updates efficiently.

Classes

AsyncState<T>
AsyncViewModelImpl<T>
Base ViewModel implementation for handling asynchronous operations with state management.
DependencyState
Provides typed access to dependency changes in onDependenciesStateChanged.
ReactiveAsyncBuilder<VM, T>
ReactiveBuilder<T>
Reactive Builder for simple state or direct model state.
ReactiveContextBuilder
ReactiveContextBuilder for explicit InheritedWidget strategy
ReactiveContextPreservationWrapper
Enhanced widget preservation with intelligent caching
ReactiveFutureBuilder<T>
A widget that handles a Future and provides reactive notification through a ReactiveNotifier to avoid flickering when navigating between screens.
ReactiveNotifier<T>
A reactive state management solution that supports:
ReactiveNotifierLifecycleObserver
Opt-in lifecycle observer to reduce memory usage when the app is inactive.
ReactiveNotifierViewModel<VM extends ViewModel<T>, T>
This class is used similarly to ReactiveNotifier, but it requires calling the ViewModel and the type of data it returns. It provides a wrapper around the ViewModel to manage state and updates via a ReactiveNotifier.
ReactiveStreamBuilder<VM, T>
ReactiveViewModelBuilder<VM, T>
ReactiveViewModelBuilder ReactiveViewModelBuilder is a specialized widget for handling ViewModel states It's designed to work specifically with StateNotifierImpl implementations and provides efficient state management and rebuilding mechanisms
ViewModel<T>
Used in ViewModel classes where all business logic should reside.

Enums

AsyncStatus
State of asynd ata, example, success, error, etc this async state shouldbe inside of asynNotifier for value of type AsyncState.

Mixins

ViewModelContextService
Mixin that provides organic context access to ViewModels Add this to ViewModel<T> and AsyncViewModelImpl<T> base classes No setup required - context is automatically available when builders are active

Extensions

ReactiveContextBase on BuildContext
Base extension for creating specific extensions
ReactiveContextGeneric on BuildContext
Optional generic extension
ReactiveContextPreservation on BuildContext
Extension methods for BuildContext preservation
ReactiveContextWidgetPreservation on Widget
Extension methods for widget preservation

Functions

cleanupPreservedWidgets() → void
Clean up all preserved widgets
getPreservationStatistics() Map<String, dynamic>
Get debug statistics for widget preservation
preserveWidget(Widget widget, [String? key]) Widget
Public API functions for widget preservation
preserveWidgets(List<Widget> widgets, [String? baseKey]) List<Widget>
Preserve multiple widgets with batch operation