https://github.com/extremevn/event_state_processor
A MVI-like Flutter package that wraps Flutter bloc package for clearer usage.
https://github.com/extremevn/event_state_processor
bloc flutter mvi
Last synced: 3 months ago
JSON representation
A MVI-like Flutter package that wraps Flutter bloc package for clearer usage.
- Host: GitHub
- URL: https://github.com/extremevn/event_state_processor
- Owner: extremevn
- License: mit
- Created: 2021-03-16T03:31:56.000Z (almost 5 years ago)
- Default Branch: main
- Last Pushed: 2022-10-06T01:35:39.000Z (over 3 years ago)
- Last Synced: 2023-08-23T06:48:20.186Z (over 2 years ago)
- Topics: bloc, flutter, mvi
- Language: Dart
- Homepage:
- Size: 2.38 MB
- Stars: 6
- Watchers: 1
- Forks: 4
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
Awesome Lists containing this project
README
# Event State Processor
A Flutter package that wrap flutter bloc package for clearer implementation. It's more similar to MVI pattern which:
- Reflect data state to view (ui)
- Process ui event to update state then make change in ui
## Getting Started
This package is use to develop app which use Bloc pattern clearer, quicker, easier by wrapping complicated bloc usage.
### Usage
#### Using ProcessorProvider instead of BlockProvider for providing
+ event processor instance or
+ create processor instance for use in child widget.
[Example apps](https://github.com/extremevn/event_state_processor/tree/main/example)
#### Implement screen widget
1. Create State extends DataState class. For ex: LoginState
2. Create Event extends UiEvent class. For ex: LoginEvent
1. Create Login screen and implement 3 function
``
class LoginScreen
extends CoreScreen
``
3.1 `createEventProcessor`: return `EventToStateProcessor` for use in this widget or its child. For ex just:
```return LoginEventProcessor();```
3.2 `buildScreenUi`: for build screen ui base on data state by using
- `buildStateBuilderWidget`
- `buildStateConsumerWidget`
- `buildStateListenerWidget`
- `buildStateSelectorWidget`
- and other widgets for UI elements which is not depended to state
For ex: if state is `state.isLoading` is true then show ProgressBar
```
buildStateBuilderWidget(
rebuildOnCondition: (p, c) => p.isLoading != c.isLoading,
builder: () => Visibility(
visible: state.isLoading, child: LoadingIndicatorWidget())),
```
## Dart Versions
- Dart 2: >= 2.6.0
## Contributor
- [Justin Lewis](https://github.com/justin-lewis) (Maintainer)
## License
[MIT](https://choosealicense.com/licenses/mit/)