stateManager property
B
stateManager
latefinal
The state manager instance for this page, automatically initialized with dependencies.
This property provides access to the state management object that can be either a Bloc (for event-driven state management) or a Cubit (for direct method calls).
In subclasses:
- BaseBlocPageState provides a typed
blocgetter that returns this as the correct Bloc type - BaseCubitPageState provides a typed
cubitgetter that returns this as the correct Cubit type
Example usage:
// In BaseBlocPageState subclasses, use the bloc getter:
bloc.add(CounterEvent.increment());
// In BaseCubitPageState subclasses, use the cubit getter:
cubit.increment();
The state manager is owned by the DI container, not by this page. It is not closed when the page is disposed, so the same instance can be rendered again by a later page.
Implementation
late final B stateManager = _resolveStateManager();