Uploaded September 2019 | Updated November 2026, 2 days ago
📗 Learn from the written tutorial 👇👇
resocoder.com/flutter-tdd-clean-architecture-ep4
👨💻 Do you write good code? Find out now!
resocoder.com/good-code-quiz
While the domain layer is the safe center of an app which is independent of other layers, the data layer is a place where the app meets with the harsh outside world of APIs and 3rd party libraries. It consists of low-level Data Sources, Repositories which are the single source of truth for the data, and finally Models.
You may have noticed that we always start working from the inner parts of the app and work our way to the outskirts. After all, we started with the completely independent domain and even there we first created the Entity. Now, we'll start with the Model and only then go ahead and implement the Repository and the low-level Data Sources.
Therefore, it makes sense to start at the center, since otherwise, we'd have a hard time implementing the Use Cases, for example, if we didn't have any Entities which can be returned first.
All of this is possible only through the power of contracts, which in the case of Dart are implemented as abstract classes. Think about it, we've fully implemented the domain layer using TDD and yet, all that the Use Cases depend on is just an abstract NumberTriviaRepository class which we've mocked with fake implementation all along...
Go to my website for more information, code examples, and articles:
● resocoder.com
Follow me on social media:
● instagram.com/resocoder
● facebook.com/resocoder
● twitter.com/resocoder
📗 Learn from the written tutorial 👇👇
resocoder.com/flutter-tdd-clean-architecture-ep4
👨💻 Do you write good code? Find out now!
resocoder.com/good-code-quiz
While the domain layer is the safe center of an app which is independent of other layers, the data layer is a place where the app meets with the harsh outside world of APIs and 3rd party libraries. It consists of low-level Data Sources, Repositories which are the single source of truth for the data, and finally Models.
You may have noticed that we always start working from the inner parts of the app and work our way to the outskirts. After all, we started with the completely independent domain and even there we first created the Entity. Now, we'll start with the Model and only then go ahead and implement the Repository and the low-level Data Sources.
Therefore, it makes sense to start at the center, since otherwise, we'd have a hard time implementing the Use Cases, for example, if we didn't have any Entities which can be returned first.
All of this is possible only through the power of contracts, which in the case of Dart are implemented as abstract classes. Think about it, we've fully implemented the domain layer using TDD and yet, all that the Use Cases depend on is just an abstract NumberTriviaRepository class which we've mocked with fake implementation all along...
Go to my website for more information, code examples, and articles:
● resocoder.com
Follow me on social media:
● instagram.com/resocoder
● facebook.com/resocoder
● twitter.com/resocoder


![Flutter TDD Clean Architecture Course [2] – Entities & Use Cases
📗 Learn from the written tutorial 👇👇
https://resocoder.com/flutter-tdd-clean-architecture-ep2
👨💻 Do you write good code? Find out now!
https://resocoder.com/good-code-quiz
In the first part, you learned the core concepts of clean architecture as it pertains to Flutter. We also created a bunch of empty folders for the presentation, domain and data layers inside the Number Trivia App were building. Now its time to start filling those empty folders with code, using TDD, of course.
Whenever you are building an app with a UI, you should design the UI and UX first. Ive done this homework for you and the app was showcased in the previous part.
The actual coding process will happen from the inner, most stable layers of the architecture outwards. This means well first implement the domain layer starting with the Entity.
Go to my website for more information, code examples, and articles:
● https://resocoder.com
Follow me on social media:
● https://instagram.com/resocoder
● https://www.facebook.com/resocoder
● https://twitter.com/resocoder Flutter TDD Clean Architecture Course [2] – Entities & Use Cases](https://i.ytimg.com/vi/lPkWX8xFthE/mqdefault.jpg)


![Flutter TDD Clean Architecture Course [5] – Contracts of Data Sources
📗 Learn from the written tutorial 👇👇
https://resocoder.com/flutter-tdd-clean-architecture-ep5
👨💻 Do you write good code? Find out now!
https://resocoder.com/good-code-quiz
Repository is the brain of the data layer of an app. It handles data from remote and local Data Sources, decides which Data Source to prefer and also, this is where data caching policy is decided upon.
In the previous part, weve gone over the basic structure of the data layer and today, its time to start implementing the data layer right from its core - from the NumberTriviaRepository, all the while creating contracts for its dependencies.
In this part, we will only create contracts for all the Repository dependencies. This will allow us to mock them easily without needing to bother with implementing them just yet - thats coming in the next parts.
Go to my website for more information, code examples, and articles:
● https://resocoder.com
Follow me on social media:
● https://instagram.com/resocoder
● https://www.facebook.com/resocoder
● https://twitter.com/resocoder Flutter TDD Clean Architecture Course [5] – Contracts of Data Sources](https://i.ytimg.com/vi/m_lkZo6CYcs/mqdefault.jpg)
![Flutter TDD Clean Architecture Course [9] – Remote Data Source
📗 Learn from the written tutorial 👇👇
https://resocoder.com/flutter-tdd-clean-architecture-ep9
👨💻 Do you write good code? Find out now!
https://resocoder.com/good-code-quiz
The last remaining part of the data layer for which we currently have only a contract is the remote Data Source. This is where all the communication with the Numbers API will happen, for which were going to use the http package. All of this will be done doing test-driven development, of course.
Go to my website for more information, code examples, and articles:
● https://resocoder.com
Follow me on social media:
● https://instagram.com/resocoder
● https://www.facebook.com/resocoder
● https://twitter.com/resocoder Flutter TDD Clean Architecture Course [9] – Remote Data Source](https://i.ytimg.com/vi/msGsYPtZnhU/mqdefault.jpg)
![Flutter Firebase & DDD Course [13] - Note Entities
📗 Get the code 👇👇
https://github.com/ResoCoder/flutter-ddd-firebase-course
📧 Get Flutter news 📰 and resources:
👉 http://flutter.education
👨💻 Do you write good code? Find out now!
https://resocoder.com/good-code-quiz
What should we do with the value objects we created in the previous part? Lets group them together into entities representing a note and a todo item.
Go to my website for more information, code examples, and articles:
● https://resocoder.com
Follow me on social media:
● https://instagram.com/resocoder
● https://www.facebook.com/resocoder
● https://twitter.com/resocoder Flutter Firebase & DDD Course [13] - Note Entities](https://i.ytimg.com/vi/myFgLD4zI3o/mqdefault.jpg)


