mirror of
https://github.com/pese-git/cherrypick.git
synced 2026-01-24 05:25:19 +00:00
add provide typedef
This commit is contained in:
@@ -13,6 +13,8 @@
|
|||||||
|
|
||||||
enum Mode { simple, instance, providerInstance, providerInstanceWithParams }
|
enum Mode { simple, instance, providerInstance, providerInstanceWithParams }
|
||||||
|
|
||||||
|
typedef Provider<T> = T? Function();
|
||||||
|
|
||||||
typedef ProviderWithParams<T> = T Function(dynamic params);
|
typedef ProviderWithParams<T> = T Function(dynamic params);
|
||||||
|
|
||||||
typedef AsyncProvider<T> = Future<T> Function();
|
typedef AsyncProvider<T> = Future<T> Function();
|
||||||
@@ -27,11 +29,12 @@ class Binding<T> {
|
|||||||
late Type _key;
|
late Type _key;
|
||||||
late String _name;
|
late String _name;
|
||||||
T? _instance;
|
T? _instance;
|
||||||
T? Function()? _provider;
|
Provider<T>? _provider;
|
||||||
|
ProviderWithParams<T>? _providerWithParams;
|
||||||
|
|
||||||
AsyncProvider<T>? asyncProvider;
|
AsyncProvider<T>? asyncProvider;
|
||||||
AsyncProviderWithParams<T>? asyncProviderWithParams;
|
AsyncProviderWithParams<T>? asyncProviderWithParams;
|
||||||
|
|
||||||
ProviderWithParams<T>? _providerWithParams;
|
|
||||||
late bool _isSingleton = false;
|
late bool _isSingleton = false;
|
||||||
late bool _isNamed = false;
|
late bool _isNamed = false;
|
||||||
|
|
||||||
@@ -95,7 +98,7 @@ class Binding<T> {
|
|||||||
/// ENG: Initialization instance via provider [value].
|
/// ENG: Initialization instance via provider [value].
|
||||||
///
|
///
|
||||||
/// return [Binding]
|
/// return [Binding]
|
||||||
Binding<T> toProvide(T Function() value) {
|
Binding<T> toProvide(Provider<T> value) {
|
||||||
_mode = Mode.providerInstance;
|
_mode = Mode.providerInstance;
|
||||||
_provider = value;
|
_provider = value;
|
||||||
return this;
|
return this;
|
||||||
|
|||||||
@@ -31,14 +31,14 @@ packages:
|
|||||||
path: "../../cherrypick"
|
path: "../../cherrypick"
|
||||||
relative: true
|
relative: true
|
||||||
source: path
|
source: path
|
||||||
version: "2.1.0-dev.1"
|
version: "2.1.0"
|
||||||
cherrypick_flutter:
|
cherrypick_flutter:
|
||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
path: "../../cherrypick_flutter"
|
path: "../../cherrypick_flutter"
|
||||||
relative: true
|
relative: true
|
||||||
source: path
|
source: path
|
||||||
version: "1.1.1-dev.1"
|
version: "1.1.1"
|
||||||
clock:
|
clock:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
|
|||||||
@@ -156,7 +156,7 @@ packages:
|
|||||||
path: "../../cherrypick"
|
path: "../../cherrypick"
|
||||||
relative: true
|
relative: true
|
||||||
source: path
|
source: path
|
||||||
version: "2.1.0-dev.1"
|
version: "2.1.0"
|
||||||
clock:
|
clock:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
|
|||||||
Reference in New Issue
Block a user