---
title: "Discussion on \"Cleaner Flutter Vol. 9: Injecting dependencies\" | Hashnode"
description: "Discussion on \"Cleaner Flutter Vol. 9: Injecting dependencies\". “Ain't got nobody that I can depend on” — Carlos Santana"
url: "https://hashnode.com/posts/cleaner-flutter-vol-9/62114f3fc6ed3906e81c32f3"
---

[Feed](https://hashnode.com/feed) /

Discussion

# [Cleaner Flutter Vol. 9: Injecting dependencies](https://marcossevilla.dev/cleaner-flutter-vol-9?utm_source=hashnode&utm_medium=feed)

“Ain't got nobody that I can depend on” — Carlos Santana

Feb 19, 2022 · 6 min read · marcossevilla.dev  
Updated Feb 26, 2022  
Read the article

-   [#dart](https://hashnode.com/tag/dart)
-   [#flutter-sdk](https://hashnode.com/tag/flutter-sdk)
-   [#clean-code](https://hashnode.com/tag/clean-code)
-   [#architecture](https://hashnode.com/tag/architecture)
-   [#dependency-injection](https://hashnode.com/tag/dependency-injection)

## Written by

[Marcos Sevilla](https://hashnode.com/@marcossevilla)

@marcossevilla · Barcelona, Spain

  
[View profile](https://hashnode.com/@marcossevilla)

Senior Engineer at Very Good Ventures

I'm a Senior Engineer at Very Good Ventures, a Flutter development consultancy. I build Flutter apps for large-scale companies and do open source work for popular Dart and Flutter packages such as Very Good CLI and Dart Frog.

## Responses 1

Markdown supported · ⌘↵ to post

[Pascal Andre](https://hashnode.com/@pjpac)

[Oct 11, 2023](https://hashnode.com/posts/cleaner-flutter-vol-9/62114f3fc6ed3906e81c32f3/comment/6526893bc4a77ce72121d850)

Hi, I'm a newbie and this series does clarify quite a lot of the questions I was having hard time to address. Many thanks for having created and shared it. Still, I was wondering if it would be possible to comment on a few things I feel I missed. a- I don't reeally see what are the differences between final bar = Bar(); and final Bar bar; In both cases, we define a variable bar of type Bar... but I am surely missing something that is not a subtlety and might also prevent me to understand fully "Foo({Bar? bar}) : \_bar = bar ?? Bar();" which is used later.

b- When stating "Our bar property is public, so we can access its methods without using foo explicitly!", I am confused as in main(), I read "foo.bar.doSomething();" which I understand as using foo explicitly, then for sure I misunderstood something but I don't know what...

c1- Regarding "Foo(this._bar);", I'm unclear why we should not use it whereas we could use "Foo({required this.bar});". Is-it because of "required" and/or "_" or because there is no ambiguity between a class attribute and a parameter name ?

c2- "You straight-up can’t use named parameters with this approach, and that can be a problem if your class needs to support more dependencies and you want to have a clean API. Just, don’t." There, the comma suggests that the impossibility to use named parameters can be a problem if we want to combine a clean API with class needing to support more dependencies. However, does it refer to having several dependency injections in the same class ? In other words, "Foo(this.\_bar);" would be OK for a single DI, but it is better to adopt a different approach to acquire some sort of a reflex which could save us from having to solve issues when several DI are associated with a single class ?

I apologize as these questions are likely to look naive, but again I'm a newbie, and I hope it could be possible to clarify these items. In any case, thanks again for this series.
