Introduction

Dependency injection (DI) supplies classes/objects in our app with other objects on which they depend. Instead of instantiating the dependent objects, a dependency injector injects the dependent objects into our class. This method becomes essential if we are building a large application with nested widgets, as the use and creation of an object are isolated.

In this lesson, we’ll work on the simple app below to add dependency injection. We will use the Get package (also known as GetX) as our dependency manager or a service locator. One of the advantages of using the get package is that it allows us to share dependencies around the application without depending on Flutter’s BuildContext object.

Get hands-on with 1400+ tech skills courses.