Flutter TDD Clean Architecture Course [4] – Data Layer Overview & Models

Flutter TDD Clean Architecture Course [4] – Data Layer Overview & Models

Reso Coder

4 года назад

47,585 Просмотров

Ссылки и html тэги не поддерживаются


Комментарии:

Kinda Lame
Kinda Lame - 07.02.2023 15:52

What was the reason for referencing the fixtures by the file name instead of the variable name? Is it just so that the variable name doesn't matter, or not to add another import?

Ответить
Carlos Pérez
Carlos Pérez - 09.09.2022 02:04

Thank you so much man, great video! I have a question: What do you do when you need to access the same entity and model from multiple features?

Ответить
Waseek Ahmed
Waseek Ahmed - 26.08.2022 20:23

This series is GOLD

Ответить
Matthew Trent
Matthew Trent - 25.08.2022 00:15

What do you do when you need to access the same entity and model from multiple features? (great vids btw!)

Ответить
D- Apps
D- Apps - 17.08.2022 18:44

You said that the entity should be independent from anything, but you are using a package inside the class, Equatable, I am not sure it a good idea. Plus you are using dartz (Either) inside the domain too. Could you please explain more about it?

Ответить
ibrahim abdal rahman Dirar
ibrahim abdal rahman Dirar - 03.05.2022 16:08

This is the best series on internet

Ответить
SEOTADEO
SEOTADEO - 18.01.2022 21:14

Ответить
Lior Polak
Lior Polak - 21.11.2021 14:26

Great

Ответить
Pedro De la Cruz
Pedro De la Cruz - 29.10.2021 22:56

Excelent content

Ответить
mehdi parsaei
mehdi parsaei - 16.10.2021 23:40

You have to make a abstract class Mapper<Entity, T>
Then your Model have to implement Mapper
Mapper have two main method
toModel
fromModel

Ответить
mehdi parsaei
mehdi parsaei - 16.10.2021 23:17

Fixtures?!!!
I did not hear that.
Use "dummy_data" instead of "mixtures" for your folder name.

Ответить
Ivan Yoed
Ivan Yoed - 08.10.2021 08:30

Top tier course. Thanks a lot Reso Coder.

Ответить
Erkin Kurt
Erkin Kurt - 12.07.2021 13:42

With this separation how would you implement JSON Serializable. Since, we need to introduce json serializable annotations into entity class because properties will be there. We are coupling json serializable package to our domain layer. Which is bad according to plug in plug out situations. So what do you think?

Ответить
Alban R
Alban R - 01.07.2021 10:26

Thank you so much for this series !

Ответить
扑克随想 - Thinking Poker
扑克随想 - Thinking Poker - 31.05.2021 10:52

When I use

expect(tNumberTriviaModel, isA<NumberTrivia>());

it returns:
Expected: <Instance of 'NumberTrivia'>
Actual: NumberTriviaModel:<NumberTriviaModel(Test Text, 1)>
Which: is not an instance of 'NumberTrivia'

Not sure if isA is expected to use as checking the parent class.

Ответить
Yash Paneliya
Yash Paneliya - 05.05.2021 14:24

the NumberTriviaRepository in domain layer is created just to write test for usecases, right?

Ответить
MEET Prajapati
MEET Prajapati - 28.04.2021 07:17

I don't know why but I really hate TDD. -_-
anyone out there like me?

Ответить
Batuhan Karababa
Batuhan Karababa - 08.04.2021 16:40

What if we want to show double when double comes from json and show int when int comes from json? Should we create 2 model classes?

Ответить
Karl Jan Reginaldo
Karl Jan Reginaldo - 17.03.2021 06:19

i think you forgot to include in the video how to implement json in pubsec.yaml

Ответить
Adriano Souza
Adriano Souza - 09.03.2021 01:26

Hi Everyone! Can somebody help me? I don't know why, but the last test fail (toJson), rewrite many times, but I guess is not a typo. It's because null safety?

Message Error:

Expected: {'text': 'Test text', 'number': 1}
Actual: {'text': null, 'number': null}
Which: at location ['text'] is <null> instead of 'Test text'

Ответить
MakeshiftGamer
MakeshiftGamer - 12.02.2021 12:54

This tutorial is awesome. Thanks :)

Ответить
Pascal Gehring
Pascal Gehring - 10.02.2021 17:13

Does anyone know how to get his aaa Test snippet?

Ответить
Ward Suleiman
Ward Suleiman - 29.01.2021 13:09

I have a question:
What are the reasons for the Model classes to extends the Entity classes?
I tried to apply this concept in my project and came to a dead end, so I had to relay on Models to feed my UI with data.
So I was wondering if there any obvious reasons for this approach?
I would like to share a snippet of my code, but that would be inappropriate here.
Finally, I would like to thank you for the great effort you put in your courses.
Keep the goodies coming !!

Ответить
hicham Mounadi
hicham Mounadi - 05.01.2021 00:11

fromJson doesn't work !! test is not working it shows error and I can't figure it out

Ответить
Luis Yauri Martinez
Luis Yauri Martinez - 25.12.2020 04:08

A los que les funciona la lectura del JSON, pueden usar este código remplazando todo fixture_reader.dart :

String fixture(String name) {
var dir = Directory.current.path;
dir = dir.replaceAll('\\', '/');
if (dir.endsWith('/test')) {
dir = dir.replaceAll('/test', '');
}
return File('$dir/test/fixtures/$name').readAsStringSync();
}

Ответить
STheo
STheo - 12.11.2020 23:48

Correct me if I am wrong but you planned the implementation of fromJson in order to accept large double numbers from the API . By converting numbers to num and then to int you cannot be sure that your code will not break in a larger number(i.e. 10^40) which is bigger than int predefined limits from the api. Generally your tutorial is great by the way .

Ответить
Pál Dorogi
Pál Dorogi - 03.11.2020 13:57

Hi Reso Coder, where would you convert an integer stored in db to a money class used in the ui? As Clean architecture confuses me (have some experience in DDD). I am asking because your entity is a subclass of model, meaning the number and the text has same type, while in my case they would be different. Thx in advance.

Ответить
Lucas Marinho
Lucas Marinho - 10.08.2020 14:41

How works model extends entity that contains a List? In my case, show me a error: "....('void Function(List<ResultMoviesRatingsModel>)') isn't a valid override of 'ResultMovieDetailsEntity.ratings='...."

Ответить
Dawid Niegrebecki
Dawid Niegrebecki - 12.07.2020 15:14

Great Video!1

Ответить
Fedor Logvinov
Fedor Logvinov - 21.06.2020 22:40

Just in case someone is stuck with error running this outside VScode.
If you have this error when trying to use code for fixture reader provided,
FileSystemException: Cannot open file, path = 'test/fixtures/trivia.json' (OS Error: No such file or directory, errno = 2)
use this code instead
import 'dart:io';
String fixture(String name) {
var dir = Directory.current.path;
if (dir.endsWith('/test')) {
dir = dir.replaceAll('/test', '');
}
return File('$dir/test/fixtures/$name').readAsStringSync();
}
it appears, that VSCode dev env is different from CLI or, say, IntelliJ (that I use), so that's more "general" solution.

Ответить
Mohammed Elfatih
Mohammed Elfatih - 19.06.2020 01:15

Thank u Reso Coder, I have a question suppose the data source am using is firestore, the response will be document instead of json, so how should apply the same concepts

Ответить
Volodymyr Bobyr
Volodymyr Bobyr - 09.05.2020 06:52

numbersapi can also return `null` for the number, which it counts as "infinity"


in order to find all possible responses, api documentation should probably be consulted

Ответить
Theo Pee
Theo Pee - 23.04.2020 12:17

How will you handle a complex list with this.

Ответить
Luis Baltodano
Luis Baltodano - 31.03.2020 16:15

Hi, why should be use a factory construc in this case?

Ответить
Djtroyan4eg
Djtroyan4eg - 14.03.2020 14:55

I have an error in test like Expected: <Instance of 'ConcreteNumberModel'>
Actual: <Instance of 'ConcreteNumberModel'>

Ответить
Scott Lu
Scott Lu - 27.02.2020 02:47

Microsoft eShopOnWeb project show an every good example of clean architecture.

Ответить
Ville-Matti Hakanpää
Ville-Matti Hakanpää - 27.02.2020 00:15

Superb stuff indeed!

One note though on fixture_reader.dart file. When you run your tests locally, this will work, but if you try to use some kind of ci tool, your tests will fail. This is because ci tools need relative path. You can add a try/catch pattern here to avoid it.

I change it to this:

import 'dart:io';


String fixture(String name) {
String jsonString;
try {
jsonString = File('test/fixtures/$name').readAsStringSync();
} catch (e) {
jsonString = File('../test/fixtures/$name').readAsStringSync();
}
return jsonString;
}

Hope this helps someone.

Ответить
Psybitcoin
Psybitcoin - 06.02.2020 22:43

If I was working on a login feature, how what would I do? For example, using Firebase: after login we receive a FirebaseUser. What entities should I create? What the model should do?

Ответить
Psybitcoin
Psybitcoin - 20.01.2020 21:03

How to write tests for example an API that returns lists of text for multiple numbers?

Ответить
Ernesto Cuesy
Ernesto Cuesy - 11.12.2019 13:41

Hi Matej, thank you for sharing your fantastic videos. I really learn a lot. Question: would it be possible for you to make a video on how to test Firebase interface in terms of documents and collections messaging back and forth? Thanks!

Ответить
Sandro Maglione
Sandro Maglione - 04.12.2019 19:17

In the written tutorial you say that in this example we do not need a Mapper class for the conversion logic.
Can you explain how you would implement a Mapper class in this project if you need to add one?

Ответить
Jesse Lima
Jesse Lima - 04.12.2019 13:53

Done!!! :D

Ответить
Jose Lara
Jose Lara - 08.11.2019 04:23

I really appreciate this man!!! you are doing the public a service, I will be refactoring all my code to follow your guidelines

Ответить
Timo Kilpilehto
Timo Kilpilehto - 02.10.2019 20:48

Nice videos. Though, did you realize that by simplifying the double case to just 1.0 you totally ended up fixing likely a non issue (assuming the api really always returns Integers) and actually masking the real problem? The problem is the numbers are way too large to be contained in ints and the real fix would be to use a suitable datatype in the first place. Your ints are now overflowing and the doubles are reduced to some entirely different garbage values making no sense e.g. 1e+40 ==> 10000000000000000000000000000000000000000.0.toInt() == 9223372036854775807

Ответить
Taha Malas
Taha Malas - 23.09.2019 16:21

Can't we use BuiltValue in the data layer for the serialization and deserialization?

Ответить
Gabriel Soares
Gabriel Soares - 21.09.2019 20:21

Very nice Course!!! Thanks man!

Ответить