flutter_service_bloc

Flutter package for service layer implement with bloc architecture

Usage

Bloc

For bloc usage please ref to service_bloc.

Listener

  • Dialog
ServiceBlocListener<ProductCheckoutServiceBloc, ProductCheckoutServiceRequested, String>(
  onLoading: (context, state, event) => showLoading(),
  onResponded: (context, state, event) => hideLoading(),
  onFailed: (context, state, event, error) => showErrorDialog(context, error),
),
  • Navigate
ServiceBlocListener<ProductCheckoutServiceBloc, ProductCheckoutServiceRequested, String>(
  onSucceed: (context, state, event, data) => Navigator.of(context).pushNamed(<your route>),
),
  • Bloc communication
ServiceBlocListener<UserLogoutServiceBloc, UserLogoutServiceRequested, dynamic>(
  onSucceed: (context, state, event, data) => context.read<UserCubit>().clearUserData(),
),

Builder

ServiceBlocBuilder<OpenLibraryAuthorDetailServiceBloc, OpenLibraryAuthorDetailServiceRequested, OpenLibraryAuthorDetail>(
  onLoading: (context, state, event) => // your loading widget,
  onSucceed: (context, state, event, data) {
    return // your success widget
  },
  onFailed: (context, state, event, error) => // your failure widget,
),

For more example detail, please check out example.

Maintainer

Jack Liu