DEV Community

Pedro Massango
Pedro Massango

Posted on

3

A Container/Dependecy Injection for Flutter apps

In the past few months We made a simple and small Container library to use internally in the company that I'm currentlly working for. It is available in this repository on GitHub. You can try it and leave some feedback. We will keep it up because we are using it for real projects.

Features

  • Create singleton instances;
  • Create factory instances (recreated on every call);
  • Register instances using Module;
  • Get instances from anywhere using the get() function.
  • Logs printed while in DEBUG mode.
  • Easy to test.
  • Doesn't use reflection.

Concepts

  • get() => Used to resolve the instance of a registered class.
  • inject() => Used to resolve a dependency inside a Module.
  • single() => Used to register a singleton instance. You will receive a the same instance every time you use get().
  • factory() => Used to register a factory instance. You will receive a new instance every time you use get().

Read more here and give it a start.

Heroku

Build apps, not infrastructure.

Dealing with servers, hardware, and infrastructure can take up your valuable time. Discover the benefits of Heroku, the PaaS of choice for developers since 2007.

Visit Site

Top comments (0)

AWS Q Developer image

Your AI Code Assistant

Generate and update README files, create data-flow diagrams, and keep your project fully documented. Built to handle large projects, Amazon Q Developer works alongside you from idea to production code.

Get started free in your IDE

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay