scopeOne<T, TScope> method

ProviderDefinition<T> scopeOne<T, 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 definition. Declare a definition T for scope TScope. Declare and define a scoped with just one line.

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

 ..scope<Login>((s) {
 s.scopedBloc((s) => LoginBloc(s.get()));
})

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

Module()..scopeOne<MyBloc, MyScope>((s) => MyBloc());

Implementation

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

///
///Standard: Used when it is necessary to declare several
///definitions for a scope.
///```
///  ..scope<Login>((s) {
///  s.scopedBloc((s) => LoginBloc(s.get()));
///})
///```
/// Declare a scope and define a scoped with just one line:
///```
/// Module()..scopeOne<MyBloc, MyScope>((s) => MyBloc());
///```
ProviderDefinition<T> scopeOne<T, TScope>(
  ProviderCreate<T> create, {
  Qualifier qualifier,
  bool createdAtStart = false,
  bool override = false,
}) {
  var scopeDefinition = ScopeDefinition(TypeQualifier(TScope), isRoot: false);
  scopeDefinitions.add(scopeDefinition);

  var beanDefinition = Definitions.saveSingle<T>(
      qualifier,
      ProviderCreateDefinition<T>(create),
      scopeDefinition,
      Options(isCreatedAtStart: createdAtStart, override: override));
  return beanDefinition;
}