mirror of
https://github.com/pese-git/cherrypick.git
synced 2026-01-23 21:13:35 +00:00
supported Dart 3.0 and fixed lint warnings
This commit is contained in:
@@ -1,6 +1,10 @@
|
||||
|
||||
# Changelog
|
||||
|
||||
2.0.0 supported 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.
|
||||
///
|
||||
|
||||
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');
|
||||
}
|
||||
|
||||
@@ -1,20 +1,21 @@
|
||||
name: cherrypick
|
||||
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/
|
||||
documentation: https://github.com/pese-git/cherrypick/wiki
|
||||
repository: https://github.com/pese-git/cherrypick
|
||||
issue_tracker: https://github.com/pese-git/cherrypick/issues
|
||||
|
||||
environment:
|
||||
sdk: ">=2.12.0 <4.0.0"
|
||||
sdk: ">=3.0.0 <4.0.0"
|
||||
|
||||
dependencies:
|
||||
meta: ^1.3.0
|
||||
|
||||
dev_dependencies:
|
||||
pedantic: ^1.11.0
|
||||
#pedantic: ^1.11.0
|
||||
|
||||
test: ^1.17.2
|
||||
|
||||
mockito: ^5.0.6
|
||||
lints: ^2.1.0
|
||||
|
||||
@@ -13,7 +13,7 @@ void main() {
|
||||
final expectedValue = 5;
|
||||
final binding = Binding<int>().toInstance(expectedValue);
|
||||
|
||||
expect(binding.mode, Mode.INSTANCE);
|
||||
expect(binding.mode, Mode.instance);
|
||||
});
|
||||
|
||||
test('Binding check singleton', () {
|
||||
@@ -48,7 +48,7 @@ void main() {
|
||||
final binding =
|
||||
Binding<int>().withName('expectedValue').toInstance(expectedValue);
|
||||
|
||||
expect(binding.mode, Mode.INSTANCE);
|
||||
expect(binding.mode, Mode.instance);
|
||||
});
|
||||
|
||||
test('Binding check key', () {
|
||||
@@ -103,7 +103,7 @@ void main() {
|
||||
final expectedValue = 5;
|
||||
final binding = Binding<int>().toProvide(() => expectedValue);
|
||||
|
||||
expect(binding.mode, Mode.PROVIDER_INSTANCE);
|
||||
expect(binding.mode, Mode.providerInstance);
|
||||
});
|
||||
|
||||
test('Binding check singleton', () {
|
||||
@@ -139,7 +139,7 @@ void main() {
|
||||
.withName('expectedValue')
|
||||
.toProvide(() => expectedValue);
|
||||
|
||||
expect(binding.mode, Mode.PROVIDER_INSTANCE);
|
||||
expect(binding.mode, Mode.providerInstance);
|
||||
});
|
||||
|
||||
test('Binding check key', () {
|
||||
@@ -200,7 +200,7 @@ void main() {
|
||||
final binding =
|
||||
Binding<int>().toProvide(() => expectedValue).singleton();
|
||||
|
||||
expect(binding.mode, Mode.PROVIDER_INSTANCE);
|
||||
expect(binding.mode, Mode.providerInstance);
|
||||
});
|
||||
|
||||
test('Binding check singleton', () {
|
||||
@@ -240,7 +240,7 @@ void main() {
|
||||
.toProvide(() => expectedValue)
|
||||
.singleton();
|
||||
|
||||
expect(binding.mode, Mode.PROVIDER_INSTANCE);
|
||||
expect(binding.mode, Mode.providerInstance);
|
||||
});
|
||||
|
||||
test('Binding check key', () {
|
||||
|
||||
Reference in New Issue
Block a user