flutter_bloc_wrapper

Last updated:

0 purchases

flutter_bloc_wrapper Image
flutter_bloc_wrapper Images
Add to Cart

Description:

flutter bloc wrapper

flutter_bloc_wrapper #
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.
copied to clipboard
Example:
void main() {
runApp(
ProcessorProvider<AuthenticationEventProcessor>(
create: (BuildContext context) => AuthenticationEventProcessor(),
child: const App(),
),
);
}
copied to clipboard
Implement screen widget


Create State extends ScreenDataState class. For ex: LoginScreenState


Create Event extends ScreenEvent class. For ex: LoginScreenEvent


Create Login screen and implement 4 function
class LoginScreen extends CoreScreen<LoginScreenEvent, LoginScreenState, LoginEventProcessor>
3.1 handleDataStateChange: handle state change after processor handle event and change widget state. For ex: press login button --> process by processor --> processor change state to LoginFailure because of invalid of login data so we want to show Alert dialog for example, do it in this function.
if (newState.error != null) {
showAlertDialog(context, Text(state.error.message));
}
copied to clipboard
3.2 createEventProcessor(State state): return EventToStateProcessor for use in this widget or its child. For ex just:
return LoginEventProcessor(state);
3.3 initScreenState: state of screen when initial
if (state.isLoading) LoadingIndicatorWidget() else Container()
3.4 buildScreen: for build screen ui base on data state. For ex: if state is state.isLoading is true then show ProgressBar
```if (state.isLoading) LoadingIndicatorWidget() else Container()```
copied to clipboard
3.5 Other 2 method initScreen and disposeScreen 2 call back when init state screen and dispose state of Screen.


Dart Versions #

Dart 2: >= 2.8.0

Maintainers #

bigzero1000

License #
MIT

License:

For personal and professional use. You cannot resell or redistribute these repositories in their original state.

Files In This Product:

Customer Reviews

There are no reviews.