scopedCubit<T extends Cubit> method

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

Defines a Cubit as scoped provider that will be automatically closed when the scope is closed. The close method of the Cubit instance created by the create will be called when the scope is closed.

Defines the Cubit for a scope:

var blocModule = Module()
..scope<ScopeWidget>((scope) {
  scope.scopedCubit<LoginCubit>((s) => LoginCubit());


ProviderDefinition<T> scopedCubit<T extends Cubit>(
  ProviderCreate<T> create, {
  Qualifier qualifier,
  bool createdAtStart = false,
  bool override = false,
}) {
  var beanDefinition =
      scoped<T>(create, qualifier: qualifier, override: override);

  beanDefinition.onClose((bloc) => bloc.close());
  return beanDefinition;