DI in Flutter. Inject your dependencies properly

By Aleksandr Denisov

Elevator Pitch

Many mobile developers, when switching to Flutter, want to use familiar approaches and solutions, for example, the Dependency Injection pattern, which provides many benefits. This talk is about DI approaches in Flutter development (Compile-time DI, Inherited Widget DI, Factory based DI).

Description

Flutter is a framework from Google that allows you to develop applications for both iOS and Android with a single code base in the Dart language and using a declarative approach to building a UI. In addition, since last year Flutter allows you to use the same code base for applications for Web and Desktop, and is gaining more and more popularity around the world. Many mobile developers, when switching to Flutter, want to use familiar approaches and solutions, for example, the Dependency Injection pattern, which provides many benefits: reduced dependencies, more reusable code, more testable code and so on. But if you type “Flutter Dependency Injection” on Google Search, the browser will provide information about a lot of packages that implement this concept. How to figure it all out, what package to choose? In this talk, I will analyze the use of DI in Flutter, considering all possible options for its implementation (Compile-time DI, Inherited Widget DI, Factory based DI), compare them with Android native implementations such as Dagger, and try to figure out what situations which implementation would be more appropriate to use.