Getting Started with Flutter application
This tutorial lets you write an Flutter/Dart application and use Koin inject and retrieve your components.
Add the Koin Flutter dependency like below:
Let's create a HelloRepository to provide some data:
Let's create business logic class, for consuming this data:
Writing the Koin module
module function to declare a module. Let's declare our first component:
?> we declare our MyBloc class as
factory to have a create a new instance each time our Widget will need one.
Now that we have a module, let's start it with Koin. Open your application class. Just call the
MyBloc component will be created with
HelloRepository instance. To get it into our Widget, let's inject it with the
by get() delegate injector:
by inject()function allows us to retrieve lazy Koin instances The
get()function is here to retrieve directly an instance (non lazy)