scopeOneDisposable<T extends Disposable, TScope> method
ProviderDefinition<T>
scopeOneDisposable<T extends Disposable, TScope>(})
Declare in a simplified way a scope that has
only one Bloc definition
.
Declare a Bloc scoped 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 Bloc scoped 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> scopeOneDisposable<T extends Disposable, TScope>(
ProviderCreate<T> create, {
Qualifier? qualifier,
bool createdAtStart = false,
bool override = false,
}) {
final beanDefinition = scopeOne<T, TScope>(create,
qualifier: qualifier,
createdAtStart: createdAtStart,
override: override);
beanDefinition.onClose((value) => value.dispose(),
onDisposeUnitialized: () {});
return beanDefinition;
}