BlocState class abstract
Abstract base class that all bloc state classes must extend.
BlocState is intentionally minimal to provide maximum flexibility while ensuring type safety in the framework. Concrete implementations should:
- Prefer immutable state when possible
- If using mutable state, document clearly why it's needed
- Consider implementing a copy or clone mechanism
- Be aware that widgets can potentially modify mutable state
While BlocState is minimal, derived states often implement:
- Immutable data structures
- Copyable state patterns
- Equatable comparisons
- Complex nested states
- Collection management
Example:
class CounterState extends BlocState {
final int count;
const CounterState({required this.count});
// Optional but recommended copy method
CounterState withCount(int newCount) =>
CounterState(count: newCount);
}
While immutable state is recommended for predictable state management, this class imposes no restrictions to support different use cases.
- Implementers
Constructors
- BlocState()
-
Creates a constant state instance.
const
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited