mirror of
https://github.com/pese-git/cherrypick.git
synced 2026-01-24 05:25:19 +00:00
supported Dart 3.0 and fixed lint warnings
This commit is contained in:
@@ -1,6 +1,10 @@
|
|||||||
|
|
||||||
# Changelog
|
# Changelog
|
||||||
|
|
||||||
|
2.0.0 supported Dart 3.0
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
1.1.0 cheked support Dart 3.0
|
1.1.0 cheked support Dart 3.0
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|||||||
@@ -1 +1,30 @@
|
|||||||
include: package:pedantic/analysis_options.yaml
|
# This file configures the static analysis results for your project (errors,
|
||||||
|
# warnings, and lints).
|
||||||
|
#
|
||||||
|
# This enables the 'recommended' set of lints from `package:lints`.
|
||||||
|
# This set helps identify many issues that may lead to problems when running
|
||||||
|
# or consuming Dart code, and enforces writing Dart using a single, idiomatic
|
||||||
|
# style and format.
|
||||||
|
#
|
||||||
|
# If you want a smaller set of lints you can change this to specify
|
||||||
|
# 'package:lints/core.yaml'. These are just the most critical lints
|
||||||
|
# (the recommended set includes the core lints).
|
||||||
|
# The core lints are also what is used by pub.dev for scoring packages.
|
||||||
|
|
||||||
|
include: package:lints/recommended.yaml
|
||||||
|
|
||||||
|
# Uncomment the following section to specify additional rules.
|
||||||
|
|
||||||
|
# linter:
|
||||||
|
# rules:
|
||||||
|
# - camel_case_types
|
||||||
|
|
||||||
|
# analyzer:
|
||||||
|
# exclude:
|
||||||
|
# - path/to/excluded/files/**
|
||||||
|
|
||||||
|
# For more information about the core and recommended set of lints, see
|
||||||
|
# https://dart.dev/go/core-lints
|
||||||
|
|
||||||
|
# For additional information about configuring this file, see
|
||||||
|
# https://dart.dev/guides/language/analysis-options
|
||||||
@@ -11,7 +11,7 @@
|
|||||||
/// limitations under the License.
|
/// 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);
|
typedef ProviderWithParams<T> = T Function(dynamic params);
|
||||||
|
|
||||||
@@ -29,7 +29,7 @@ class Binding<T> {
|
|||||||
late bool _isNamed = false;
|
late bool _isNamed = false;
|
||||||
|
|
||||||
Binding() {
|
Binding() {
|
||||||
_mode = Mode.SIMPLE;
|
_mode = Mode.simple;
|
||||||
_key = T;
|
_key = T;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -78,7 +78,7 @@ class Binding<T> {
|
|||||||
///
|
///
|
||||||
/// return [Binding]
|
/// return [Binding]
|
||||||
Binding<T> toInstance(T value) {
|
Binding<T> toInstance(T value) {
|
||||||
_mode = Mode.INSTANCE;
|
_mode = Mode.instance;
|
||||||
_instance = value;
|
_instance = value;
|
||||||
_isSingleton = true;
|
_isSingleton = true;
|
||||||
return this;
|
return this;
|
||||||
@@ -89,7 +89,7 @@ class Binding<T> {
|
|||||||
///
|
///
|
||||||
/// return [Binding]
|
/// return [Binding]
|
||||||
Binding<T> toProvide(T Function() value) {
|
Binding<T> toProvide(T Function() value) {
|
||||||
_mode = Mode.PROVIDER_INSTANCE;
|
_mode = Mode.providerInstance;
|
||||||
_provider = value;
|
_provider = value;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
@@ -99,7 +99,7 @@ class Binding<T> {
|
|||||||
///
|
///
|
||||||
/// return [Binding]
|
/// return [Binding]
|
||||||
Binding<T> toProvideWithParams(ProviderWithParams<T> value) {
|
Binding<T> toProvideWithParams(ProviderWithParams<T> value) {
|
||||||
_mode = Mode.PROVIDER_WITH_PARAMS_INSTANCE;
|
_mode = Mode.providerInstanceWithParams;
|
||||||
_providerWithParams = value;
|
_providerWithParams = value;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -61,7 +61,9 @@ class Scope {
|
|||||||
/// return [Scope]
|
/// return [Scope]
|
||||||
Scope installModules(List<Module> modules) {
|
Scope installModules(List<Module> modules) {
|
||||||
_modulesList.addAll(modules);
|
_modulesList.addAll(modules);
|
||||||
modules.forEach((module) => module.builder(this));
|
for (var module in modules) {
|
||||||
|
module.builder(this);
|
||||||
|
}
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -110,11 +112,11 @@ class Scope {
|
|||||||
((!binding.isNamed && named == null) ||
|
((!binding.isNamed && named == null) ||
|
||||||
(binding.isNamed && named == binding.name))) {
|
(binding.isNamed && named == binding.name))) {
|
||||||
switch (binding.mode) {
|
switch (binding.mode) {
|
||||||
case Mode.INSTANCE:
|
case Mode.instance:
|
||||||
return binding.instance;
|
return binding.instance;
|
||||||
case Mode.PROVIDER_INSTANCE:
|
case Mode.providerInstance:
|
||||||
return binding.provider;
|
return binding.provider;
|
||||||
case Mode.PROVIDER_WITH_PARAMS_INSTANCE:
|
case Mode.providerInstanceWithParams:
|
||||||
if (params == null) {
|
if (params == null) {
|
||||||
throw StateError('Param is null. Maybe you forget pass it');
|
throw StateError('Param is null. Maybe you forget pass it');
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,20 +1,21 @@
|
|||||||
name: cherrypick
|
name: cherrypick
|
||||||
description: Cherrypick is a small dependency injection (DI) library for dart/flutter projects.
|
description: Cherrypick is a small dependency injection (DI) library for dart/flutter projects.
|
||||||
version: 1.1.0
|
version: 2.0.0
|
||||||
homepage: https://pese-git.github.io/cherrypick-site/
|
homepage: https://pese-git.github.io/cherrypick-site/
|
||||||
documentation: https://github.com/pese-git/cherrypick/wiki
|
documentation: https://github.com/pese-git/cherrypick/wiki
|
||||||
repository: https://github.com/pese-git/cherrypick
|
repository: https://github.com/pese-git/cherrypick
|
||||||
issue_tracker: https://github.com/pese-git/cherrypick/issues
|
issue_tracker: https://github.com/pese-git/cherrypick/issues
|
||||||
|
|
||||||
environment:
|
environment:
|
||||||
sdk: ">=2.12.0 <4.0.0"
|
sdk: ">=3.0.0 <4.0.0"
|
||||||
|
|
||||||
dependencies:
|
dependencies:
|
||||||
meta: ^1.3.0
|
meta: ^1.3.0
|
||||||
|
|
||||||
dev_dependencies:
|
dev_dependencies:
|
||||||
pedantic: ^1.11.0
|
#pedantic: ^1.11.0
|
||||||
|
|
||||||
test: ^1.17.2
|
test: ^1.17.2
|
||||||
|
|
||||||
mockito: ^5.0.6
|
mockito: ^5.0.6
|
||||||
|
lints: ^2.1.0
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ void main() {
|
|||||||
final expectedValue = 5;
|
final expectedValue = 5;
|
||||||
final binding = Binding<int>().toInstance(expectedValue);
|
final binding = Binding<int>().toInstance(expectedValue);
|
||||||
|
|
||||||
expect(binding.mode, Mode.INSTANCE);
|
expect(binding.mode, Mode.instance);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('Binding check singleton', () {
|
test('Binding check singleton', () {
|
||||||
@@ -48,7 +48,7 @@ void main() {
|
|||||||
final binding =
|
final binding =
|
||||||
Binding<int>().withName('expectedValue').toInstance(expectedValue);
|
Binding<int>().withName('expectedValue').toInstance(expectedValue);
|
||||||
|
|
||||||
expect(binding.mode, Mode.INSTANCE);
|
expect(binding.mode, Mode.instance);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('Binding check key', () {
|
test('Binding check key', () {
|
||||||
@@ -103,7 +103,7 @@ void main() {
|
|||||||
final expectedValue = 5;
|
final expectedValue = 5;
|
||||||
final binding = Binding<int>().toProvide(() => expectedValue);
|
final binding = Binding<int>().toProvide(() => expectedValue);
|
||||||
|
|
||||||
expect(binding.mode, Mode.PROVIDER_INSTANCE);
|
expect(binding.mode, Mode.providerInstance);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('Binding check singleton', () {
|
test('Binding check singleton', () {
|
||||||
@@ -139,7 +139,7 @@ void main() {
|
|||||||
.withName('expectedValue')
|
.withName('expectedValue')
|
||||||
.toProvide(() => expectedValue);
|
.toProvide(() => expectedValue);
|
||||||
|
|
||||||
expect(binding.mode, Mode.PROVIDER_INSTANCE);
|
expect(binding.mode, Mode.providerInstance);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('Binding check key', () {
|
test('Binding check key', () {
|
||||||
@@ -200,7 +200,7 @@ void main() {
|
|||||||
final binding =
|
final binding =
|
||||||
Binding<int>().toProvide(() => expectedValue).singleton();
|
Binding<int>().toProvide(() => expectedValue).singleton();
|
||||||
|
|
||||||
expect(binding.mode, Mode.PROVIDER_INSTANCE);
|
expect(binding.mode, Mode.providerInstance);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('Binding check singleton', () {
|
test('Binding check singleton', () {
|
||||||
@@ -240,7 +240,7 @@ void main() {
|
|||||||
.toProvide(() => expectedValue)
|
.toProvide(() => expectedValue)
|
||||||
.singleton();
|
.singleton();
|
||||||
|
|
||||||
expect(binding.mode, Mode.PROVIDER_INSTANCE);
|
expect(binding.mode, Mode.providerInstance);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('Binding check key', () {
|
test('Binding check key', () {
|
||||||
|
|||||||
Reference in New Issue
Block a user