Stateful extension is built to support data loading and submission
patterns which are commonly implemented using Bloc.
Each one of them usually consist of the following states:
They are commonly used as follows:
initialStateset in constructor
- when the action is triggered the
- some logic is executed to fetch / send / transform the data
- depending on the outcome
This extension abstracts away both the state types and their transitions leaving only the logic to be supplied by the implementer.
Example of a generic cubit that provides state to a page, allowing it to display a loading indicator and error message
|Pure cubit||Stateful cubit|
|Pure cubit state||Stateful state|
Main advantages of using the Stateful extension:
- Cubit / Bloc simplification - you don't have to worry about states, just focus on the logic and the data it changes
- State simplification - no more repeating the same inheritance tree for each component, just focus on the data that's being provided
- Uniform state types across the whole codebase - aside from
the standardization itself this makes it easier to reuse state dependent
widgets across multiple UI components (like showing a loading indicator
ActionStatus.ongoingor an error message on
This library is licenced under
- Extension to the Bloc library that simplifies common state transition sequences.