useWithKey<T> method
It works just like use function, but instead of type, you use with key. You have to inject using injectWithKey function first.
final appSecret = Okito.useWithKey<String>('appSecret');
final firstCounterController =
Okito.useWithKey<CounterController>('controller1');
final secondCounterController =
Okito.useWithKey<CounterController>('controller2');
Implementation
T useWithKey<T>(String key) {
if (_dependenciesWithKey.containsKey(key)) {
return _dependenciesWithKey[key];
}
throw Exception('''
You have to inject a variable with key to use [useWithKey] function.
Please read the documents or hover over the [useWithKey] function to see its usage.
Note that you can't use type [dynamic] with [useWithKey] function.
''');
}