minimal_di

Last updated:

0 purchases

minimal_di Image
minimal_di Images
Add to Cart

Description:

minimal di

di #
Flutter Dependency Injection package for minimalist.
just 6 simple features #
abstract class IDependencyInjection
{
bool isRegistered<T extends Object>({String? named});
void register<T extends Object>(T instance, {String? named});
void registerLazy<T extends Object>(Future<T> Function() func, {String? named});
void change<T extends Object>(T instance, {String? named});
T get<T extends Object>({String? named});
Future<T> getAsync<T extends Object>({String? named});
}
copied to clipboard
Usage #
Future<int> initNumber(String number) async
{
var parsed = int.tryParse(number);
parsed ??= 1;
await Future.delayed(Duration(seconds: parsed));
return parsed;
}

DI.instance.registerLazy<int>(() => initNumber("1"), named:"one");
var one = await DI.instance.getAsync<int>(named: "one");
assert(one == 1);

copied to clipboard
if you do not pass named argument, default values is runtimeType.toString()

License:

For personal and professional use. You cannot resell or redistribute these repositories in their original state.

Files In This Product:

Customer Reviews

There are no reviews.