scopeOneCubit<T extends Cubit, TScope> method

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

Declare in a simplified way a scope that has only one a Cubit by create. Declare a Cubit scoped provider T for scope TScope. Declare and define a scoped with just one line.

Standard: Used when it is necessary to declare several providers for a scope.

 ..scope<Login>((s) {
 s.scopedStream((s) => LoginCubit(s.get()));
})

Declare a scope and define a scoped provider with just one line:

Module()..scopeOneCubit<LoginCubit, MyScope>((s) => LoginCubit());

Implementation

/// Declare a Cubit scoped provider [T] for scope [TScope].
/// Declare and define a scoped with just one line.

///
///Standard: Used when it is necessary to declare several
///providers for a scope.
///```
///  ..scope<Login>((s) {
///  s.scopedStream((s) => LoginCubit(s.get()));
///})
///```
/// Declare a scope and define a scoped provider with just one line:
///```
/// Module()..scopeOneCubit<LoginCubit, MyScope>((s) => LoginCubit());
///```
ProviderDefinition<T> scopeOneCubit<T extends Cubit, TScope>(
  ProviderCreate<T> create, {
  Qualifier qualifier,
  bool createdAtStart = false,
  bool override = false,
}) {
  final providerDefinition = scopeOne<T, TScope>(create,
      qualifier: qualifier,
      createdAtStart: createdAtStart,
      override: override);
  providerDefinition.onClose((cubit) => cubit.close());
  return providerDefinition;
}