mirror of
https://github.com/pese-git/cherrypick.git
synced 2026-01-26 14:50:17 +00:00
supported Dart 3.0 and fixed lint warnings
This commit is contained in:
@@ -11,7 +11,7 @@
|
||||
/// limitations under the License.
|
||||
///
|
||||
|
||||
enum Mode { SIMPLE, INSTANCE, PROVIDER_INSTANCE, PROVIDER_WITH_PARAMS_INSTANCE }
|
||||
enum Mode { simple, instance, providerInstance, providerInstanceWithParams }
|
||||
|
||||
typedef ProviderWithParams<T> = T Function(dynamic params);
|
||||
|
||||
@@ -29,7 +29,7 @@ class Binding<T> {
|
||||
late bool _isNamed = false;
|
||||
|
||||
Binding() {
|
||||
_mode = Mode.SIMPLE;
|
||||
_mode = Mode.simple;
|
||||
_key = T;
|
||||
}
|
||||
|
||||
@@ -78,7 +78,7 @@ class Binding<T> {
|
||||
///
|
||||
/// return [Binding]
|
||||
Binding<T> toInstance(T value) {
|
||||
_mode = Mode.INSTANCE;
|
||||
_mode = Mode.instance;
|
||||
_instance = value;
|
||||
_isSingleton = true;
|
||||
return this;
|
||||
@@ -89,7 +89,7 @@ class Binding<T> {
|
||||
///
|
||||
/// return [Binding]
|
||||
Binding<T> toProvide(T Function() value) {
|
||||
_mode = Mode.PROVIDER_INSTANCE;
|
||||
_mode = Mode.providerInstance;
|
||||
_provider = value;
|
||||
return this;
|
||||
}
|
||||
@@ -99,7 +99,7 @@ class Binding<T> {
|
||||
///
|
||||
/// return [Binding]
|
||||
Binding<T> toProvideWithParams(ProviderWithParams<T> value) {
|
||||
_mode = Mode.PROVIDER_WITH_PARAMS_INSTANCE;
|
||||
_mode = Mode.providerInstanceWithParams;
|
||||
_providerWithParams = value;
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -61,7 +61,9 @@ class Scope {
|
||||
/// return [Scope]
|
||||
Scope installModules(List<Module> modules) {
|
||||
_modulesList.addAll(modules);
|
||||
modules.forEach((module) => module.builder(this));
|
||||
for (var module in modules) {
|
||||
module.builder(this);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -110,11 +112,11 @@ class Scope {
|
||||
((!binding.isNamed && named == null) ||
|
||||
(binding.isNamed && named == binding.name))) {
|
||||
switch (binding.mode) {
|
||||
case Mode.INSTANCE:
|
||||
case Mode.instance:
|
||||
return binding.instance;
|
||||
case Mode.PROVIDER_INSTANCE:
|
||||
case Mode.providerInstance:
|
||||
return binding.provider;
|
||||
case Mode.PROVIDER_WITH_PARAMS_INSTANCE:
|
||||
case Mode.providerInstanceWithParams:
|
||||
if (params == null) {
|
||||
throw StateError('Param is null. Maybe you forget pass it');
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user