value_bloc

GitHubpub.dev
value_blocvalue_bloc
flutter_value_blocflutter_value_bloc

Getting Started

You can find many cubits that are right for you.

Modular cubits

You can integrate modules into your cubits

LoadCubitModule

For example you can mix LoadCubitModule to integrate a load function

class MyCubit extends ModularCubit<State> with LoadCubitModule {
  void onLoading() {
    // write your code for initializing bloc
    emitLoading();
  }
}

Local Value/s cubits

Cubit as: ValueCubit, ListCubit, SetCubit is recommended to use as described below

class MyCubit extends Cubit<State> {
  final userCubit = ValueCubit<User, Object>();
  
  MyCubit() {
    userCubit.updateValue(value: User('Piero'));
  }
}

Fetch Value/s cubits

Cubist as: SingleCubit and MultiCubit is recommended to use as described below

class MyCubit extends Cubit<State> {
  final userCubit = SingleCubit<User, Filter, Object>();
  
  MyCubit() {
    userCubit.fetcher(fetcher: _fetcher);
  }
  
  _fetcher(Filter filter) async* {
    if (filter == Filter.empty) {
      yield SingleFetchEvent.empty();
    } else {
      yield SingleFetchEvent.fetched(User('Piero'));
    }
  }
}

Libraries

ignore
value_bloc