gbtb16/kiwi

Register Type from imported package

as001622 opened this issue · 2 comments

Hello!
How to register some Type from imported package, which doesn't have a constructor, but instead has a getInstance() method, witch return Future. As example SharedPreferences.

Hello,
Sorry I completed missed this.
If the instance is returned within a Future the first thing to do is to await it in order to get the instance. Then you can call container.registerInstance(myInstance);

@as001622 what @letsar said is indeed correct you should do something like this:

final myInstance = await YourClass.getFuture();
container.registerInstance(myInstance);

If you still have questions about this, feel free to comment, reopen the ticket.