supported Dart 3.0 and fixed lint warnings

This commit is contained in:
Sergey Penkovsky
2023-05-22 15:58:03 +03:00
parent f94c2df7cd
commit 938f8df8b6
6 changed files with 55 additions and 19 deletions

View File

@@ -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;
}

View File

@@ -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');
}