cubit<T extends Cubit> method

ProviderDefinition<T> cubit<T extends Cubit>(
  1. ProviderCreate<T> create,
  2. {Qualifier qualifier,
  3. bool createdAtStart = false,
  4. bool override = false}
)

Defines a Cubit as single provider that will be automatically closed. The close method of the Cubit created by the create will be called when the global context of the koin is finalized.

Define the Cubit:

var myModule = Module()..cubit((s) => MyCubit());

Implementation

ProviderDefinition<T> cubit<T extends Cubit>(
  ProviderCreate<T> create, {
  Qualifier qualifier,
  bool createdAtStart = false,
  bool override = false,
}) {
  var providerDefinition = single<T>(create,
      qualifier: qualifier,
      createdAtStart: createdAtStart,
      override: override);

  providerDefinition.onClose((cubit) => cubit.close());
  return providerDefinition;
}