Freezed ❄ – Data Class & Union in One Dart Package

preview_player
Показать описание
📗 Learn from the written tutorial 👇👇

📧 Get Flutter news 📰 and resources:

👨‍💻 Do you write good code? Find out now!

How would you like it if Dart had data classes and sealed classes as we know them from Kotlin? It would be perfect but while these features are being worked on, they're still in the distant future. Now we have the next best thing though - we're all about to get freezed with the new package by Rémi Rousselet, the creator of provider.

If you've been following Dart's algebraic data type scene for a while you might be thinking "We have sealed_unions, super_enum, sum_types... Why do we need yet another package?". (Yes, I did cover all of those packages with tutorials 😉) Similarly, if you are an avid follower of the data class scene, built_value, equatable and even certain VS Code extensions may come to mind. So, why again another package?

Go to my website for more information, code examples, and articles:

Follow me on social media:
Рекомендации по теме
Комментарии
Автор

This tutorial *WORKS* even with the new version *0.6*
Just use the @freezed annotation from the *freezed_annotation* package.

ResoCoder
Автор

I don't know why, but your tutorials are the only ones that make sense to me! I had absolutely no motivation to learn all that stuff until I stumbled over your videos. Coming from Web, many packages and solutions seem to solve problems I don't know from typescript. Thank you so much! Keep up the good work! Perfectly organized information! 👌

Chlldkrote
Автор

This is so concise, clear, and convenient! Thanks, Reso Coder!!!! Love it

josephcobbinah
Автор

ok I finally get unions and a useful way to use them and it is brilliant. TY for this tutorial!

devorrahtester
Автор

I came here after complete watching of 1 and in other half you recommend me to watch this ..now i am feeling sleepy and washed my face and again start watching ..great video matt love you

RohitSharma-cwii
Автор

in my opinion, for data class it is better to use plugin "Dart Data Class", it just generates all methods and construcors (including json conversion) that freezed does, you only put fields inside a class, hit generate option and that's it, less boiler code to write yourself compering to freezed, the generated code is much more cleaner

rsobies
Автор

@Reso Coder How would you apply this in your Clean Architecture? I was trying to use the Freezed package with the Models & Entities but I couldn't find a way to extend the model to the entity.

markoliverbaltazar
Автор

I love the way to tell us where to use it in real application.
great job, be continued.
your videos is extremely useful

arahussein
Автор

Thank you, very useful! I have a question if sombody could answer: Is possible to declare once the shared fields between unions?

mr.spokebeats
Автор

Thanks for this fast clear summary. :-)

tenhobi
Автор

Very nice, but can we separate on domain and model? like clear architecture?

eduardoholzmann
Автор

Awesome video man! One question before I decide to adopt the code generation using freezed. If I change the location of the part file will it create the folder and put all the generated code in there? I want to have the generated filed in a generation folder since that code won't be manually modified. I usually have 10-20 data classes so I want to avoid having additional 2 files for each of those in the same folder.

FilledStacks
Автор

I am convinced this is going to be useful

SEOTADEO
Автор

Ur doing an awesome work bro ur voice nd ur way of me this is the best flutter channel ❤️🔥🔥

samsurya
Автор

You make one one the best videos.
I m not able to join your bootcamps they are too price but once I accumulate that much money. I will join you one day.

One question...

Can I included fields like color or IconData in data class. If I do so I receive any error while running build command.

findsarfaraz
Автор

Good job on that, thanks a million. As I am now working on that in newer versions, I encounter the following error: it doesn't want to accept the @freezed annotation unless I use "import (While using only dart ...). Unfortunately it builds then, but doesn't run... Don't know why the example wont work ...

Just in case you have time to answer I happily appreciate that !

TheDaple
Автор

good but sealed union concept is still hard to get it :) i would need another in depth theoritical tutorial ☺️ .. any news if the dart team is about to offer native sealed unions ?

arnaudduquenoy
Автор

I do not know if I understand correctly. Union classes are responsible for handling use cases? For example, a document in a firestore - I am creating a union class with add, update and delete methods?

krenoys
Автор

`flutter pub run build_runner watch --delete-conflicting-outputs` from where do we know more about this cmd ?
great video :) ty

ajinkyax
Автор

When you started listing the packages at the beginning of the video... man, I felt that, it's confusing sometimes with all the packages providing workarounds for the Dart language.

vincevarga