Mastering Clean Architecture & Repository Pattern in Flutter

  Рет қаралды 19,468

David Serrano

David Serrano

Күн бұрын

Take your Flutter skills to the next level with this Flutter tutorial. Learn how to apply SOLID principles and manage data from a remote API with ease using the Repository Pattern and Clean Architecture framework. You'll come away with the tools to create cleaner, more scalable code that's easy to maintain and update in your own Flutter projects.
☺ Support the channel:
Any donation is gratefully received, thank you!
- Via my website: davidserrano.io/sponsor
- Via KZbin's Super Thanks (⬆ Button labeled THANKS above ⬆)
🔔 Subscribe:
Subscribe to my channel to see more videos like this:
www.youtube.com/@david-serrano...
📖 Useful resources:
- Remote API used in this tutorial:
rapidapi.com/SAdrian/api/movi...
- Quicktype (quickly convert JSON to Dart entities):
app.quicktype.io/
- Open source project created in this video:
github.com/svprdga/Flutter-Mo...
📖 Flutter libraries used:
- In this tutorial, freezed is used to generate the domain models:
pub.dev/packages/freezed
- Data models are autogenerated with json_serializable:
pub.dev/packages/json_seriali...
- The logger package is used to write to the log:
pub.dev/packages/logger
- The provider package is used for dependency injection and state management:
pub.dev/packages/provider
- Images are displayed and cached with the cached_network_image package:
pub.dev/packages/cached_netwo...
- Internationalization and language-related tools:
pub.dev/packages/intl
- You can create an infinite scrollable list with infinite_scroll_pagination:
pub.dev/packages/infinite_scr...
- We will use sqflite to work with a local database:
pub.dev/packages/sqflite
🔵 Follow me:
Find out about my latest videos and publications:
davidserrano.io/
/ svprdga
hashnode.com/@svprdga
dev.to/svprdga
mastodon.social/@svprdga
⏳ Timecodes:
00:00 - Introduction
02:15 - Project setup & domain model creation with freezed
06:27 - Create the network entity models
08:07 - Map network entities to domain models
10:45 - Create the API client with dio
15:21 - Create the Movie Repository
19:13 - Load local configuration & setup dependency injection tree
26:10 - Create MoviePreview widget
30:26 - Infinite scrollable list with infinite_scroll_pagination
33:47 - Create the database entities
36:37 - Database mapper & Data Access Objects (DAO)
41:38 - Adjust the repository to work with the database
44:50 - Synchronize the local database with new data available in the API
50:34 - Dart analyze, Dart format, and final conclusion

Пікірлер: 39
@oscarisorez7829
@oscarisorez7829 5 ай бұрын
This video is a gold mine of information
@DavidSerranoIO
@DavidSerranoIO 5 ай бұрын
Thanks ☺️
@theflutterboi
@theflutterboi Жыл бұрын
Amazingly explained. Please make more videos like this.
@nevilleraheemdavis5568
@nevilleraheemdavis5568 4 ай бұрын
Underrated video 🎉🎉🎉
@DavidSerranoIO
@DavidSerranoIO 4 ай бұрын
Thx!!
@martinmj94
@martinmj94 Жыл бұрын
So impressed and grateful for how clear and well paced this tutorial was. I have not used the data/domain/presentation architecture before but will attempt to implement it in my current project at work using this video as a reference.
@DavidSerranoIO
@DavidSerranoIO Жыл бұрын
I am very glad that it has been useful to you! Thank you very much for your support 🙂
@seamensclubltd7603
@seamensclubltd7603 7 ай бұрын
huge thanks!!
@DavidSerranoIO
@DavidSerranoIO 7 ай бұрын
You're welcome!!
@MultiDesignWork
@MultiDesignWork 7 ай бұрын
Great tutorial, you have a great pace for tutoring, something that is lacking at a lot of Flutter videos.
@DavidSerranoIO
@DavidSerranoIO 7 ай бұрын
Thank you! And thank you also for the compliment 🤗
@satishsharma1298
@satishsharma1298 11 ай бұрын
This tutorial is so useful I am a new learner and thanks to you for this. Great content.
@DavidSerranoIO
@DavidSerranoIO 11 ай бұрын
I'm glad you found it useful, thanks for your kind words!
@eincandela
@eincandela 10 ай бұрын
Very concise and instructive video
@DavidSerranoIO
@DavidSerranoIO 10 ай бұрын
Thanks!
@danielvelez5493
@danielvelez5493 5 ай бұрын
I like is perfect
@ayesigasteven8058
@ayesigasteven8058 7 ай бұрын
Thank you
@DavidSerranoIO
@DavidSerranoIO 7 ай бұрын
You're welcome!
@Inandoutpk
@Inandoutpk 6 ай бұрын
Thank you so much for this wonderful tutorials.
@DavidSerranoIO
@DavidSerranoIO 6 ай бұрын
You're welcome! :)
@Inandoutpk
@Inandoutpk 6 ай бұрын
​@@DavidSerranoIO I have a question, I take freelancing projects that are not huge and most of them have firebase as backends. and I have two questions please answer them. Should I implement CLEAN Architecture in small freelance projects that use Firebase as the backend? Can I use CLEAN Architecture with GetX ?
@DavidSerranoIO
@DavidSerranoIO 6 ай бұрын
@@Inandoutpk In my opinion, yes, you should always apply clean architecture. As for GetX, I suppose you can apply clean, but I strongly advise against using this library, since what it does is an over-engineering of Flutter itself, from my point of view it makes no sense and does not provide anything of value.
@Inandoutpk
@Inandoutpk 6 ай бұрын
@@DavidSerranoIO Thanks for your suggestion, I think now I should move toward riverpods.
@DavidSerranoIO
@DavidSerranoIO 6 ай бұрын
@@Inandoutpk Good choice 👍
@usama_khalid
@usama_khalid Жыл бұрын
👍
@benjieming7232
@benjieming7232 8 ай бұрын
Retrofit over custom ApiClient
@ilyasanders4169
@ilyasanders4169 6 ай бұрын
@hurbangash1302
@hurbangash1302 2 ай бұрын
siriam using riverpod and i have heard that riverpod is anti architecture need help how can i use clean archetecture for riverpod
@nevilleraheemdavis5568
@nevilleraheemdavis5568 4 ай бұрын
Followed up to the point where you passed the 'providers' parameter to App().. this is making my widget_test.dart fail since i can't access the given parameter in that widget_test.dart file, any suggestions?
@DavidSerranoIO
@DavidSerranoIO 4 ай бұрын
You can send a list of providers prepared for your test, what specific error are you having?
@nekorielfredbear1455
@nekorielfredbear1455 Жыл бұрын
hello you said to me: You're welcome, if you want, when I launch the video, remind me in a comment and I'll explain exactly what you would have to do to incorporate Firestore. so if you want to explain it to me that would be adorable thank you !!!
@DavidSerranoIO
@DavidSerranoIO Жыл бұрын
Of course, basically you have to follow the same methodology that I follow in this video but adjusting the datasource to Firestore, that is: - First create an entity that represents the data in Firestore, for example lib/data/firestore/entity/your_entity.dart. Here you can use json_serializable exactly like I do with the network layer models. - Then you'll need a mapper to convert that entity to your domain objects, which can be in lib/data/firestore/firestore_mapper.dart. The methodology to follow is exactly the same as the Mapper classes that I show in this example. - You will have to create the datasource that interacts with Firestore, in /lib/data/firestore/client/firestore_client.dart. This class uses the SDK that Firestore provides to work with its data. - Finally you will have to use all of the above in your repository, where you will use FirestoreClient to get the entities, and FirestoreMapper to map them to your domain objects. This is roughly the guide by which you could guide yourself to be able to implement your synchronization layer with Firestore, if you have any specific questions do not hesitate to ask.
@nekorielfredbear1455
@nekorielfredbear1455 Жыл бұрын
@@DavidSerranoIO Hello, I'm coming back to you because I'm stuck, indeed, I can't find the api host for cloud firestore, as for my api key, I retrieved my web api key from the parameters of my firebase project, hoping that this is it
@DavidSerranoIO
@DavidSerranoIO Жыл бұрын
@@nekorielfredbear1455 To communicate with Firestore you have to use the library and the methodology that Firebase requires. I recommend that you first learn to read and write in Firebase by following the official tutorials offered by Google. Once you've learned that, you can apply that knowledge to building a FirestoreClient to perform the communication.
@nekorielfredbear1455
@nekorielfredbear1455 Жыл бұрын
@@DavidSerranoIO thank you
@debajyotisaha4289
@debajyotisaha4289 Жыл бұрын
After running the application, my application shows blank screen. The Data is logging in my console. but after that it becomes null. Any solution?
@DavidSerranoIO
@DavidSerranoIO Жыл бұрын
Could you provide the complete log output?
@Anilkumar-ec8sj
@Anilkumar-ec8sj 11 ай бұрын
why you didn't go for hive and used SQLite?
@DavidSerranoIO
@DavidSerranoIO 11 ай бұрын
Because SQLite is a suitable tool for this task. Why should I have used Hive instead in your opinion?
Repository Pattern
11:08
Coding Concepts
Рет қаралды 66 М.
WHO LAUGHS LAST LAUGHS BEST 😎 #comedy
00:18
HaHaWhat
Рет қаралды 20 МЛН
50 YouTubers Fight For $1,000,000
41:27
MrBeast
Рет қаралды 95 МЛН
Flutter Clean Architecture Visual Explanation
6:15
Flutter Mapp
Рет қаралды 25 М.
Fix a memory leak in Flutter (#148291)  | Building Flutter
1:06:27
Flutter Bounty Hunters
Рет қаралды 4,1 М.
Clean Architecture in Flutter with Example !
8:05
AI with Flutter
Рет қаралды 1 М.
Weather App • FLUTTER - BLOC & API Tutorial for Beginners 🔥
1:01:59
Noob To Pro: 10 Epic UI Packages in Flutter - 2024
4:23
AstroDevs
Рет қаралды 31 М.
Why do we use DTOs in our APIs?
26:15
Codewrinkles
Рет қаралды 8 М.
The First Step To Clean Architecture | Flutter SOLID Principles
28:27
Rivaan Ranawat
Рет қаралды 14 М.
Я УКРАЛ ТЕЛЕФОН В МИЛАНЕ
9:18
Игорь Линк
Рет қаралды 107 М.
Мой инст: denkiselef. Как забрать телефон через экран.
0:54