Freezed (Package of the Week)
Вставка
- Опубліковано 8 гру 2021
- Learn more about product → goo.gle/3oAtlne
Tired of writing tedious boilerplate for simple data classes? Try Freezed, a code generation package in Dart that can accelerate your development.
This video is also subtitled in Chinese, Indonesian, Italian, Japanese, Korean, Portuguese, and Spanish.
Learn everything about Flutter at → goo.gle/2WAhEN1
Get more tips! → goo.gle/FlutterPackage
Subscribe to Flutter! → goo.gle/FlutterYT
#PackageoftheWeek #Widgets #Flutter
product: Flutter - Development - User interface; fullname: Craig Labenz; - Наука та технологія
Nice, but would be good for Dart to actually implement data classes
Code generation in dart is janky and terrible. It's not the same as language features.
yeah, even the fact that they announced Freezed as Package of the Week it is not even funny. There shouldn't be such package for "modern language" as Dart at the first place
Sometimes code generation takes too much time
Code gen is fully headache
I have worked on some projects using freezed as suggested by my team colleague and i found it really pain while dealing with states between immutable freezed classes and what i like about freezed is it's saves us from running into bugs by showing errors in line editing thats all rest is so tiring and complex work and a lot of generated codes with multiole files and 80% of those generated codes are not even used most of the time ahh its really terrible experience fr me and its not flexible you have to use .copyWith or create new var and assign the freezed values to the new then only you can modify the values really pain
.
You know the code generation packages are a huge crutch of a solution. And a clear sign of the language/framework missing something vital within itself. I hope your team will be able to get rid of the necessity to use such kinds of hacks that overcomplicate our codebases with 3rd party syntax
the answer is reflection but flutter will never support that
Totally agreed. Sad to see that instead offering stable solutions Google team offers such ugly unprofessional hacks
@@giorgospapadakis7613 may I ask why it will never happen?
Couldn't say more accurate, man. Long story of using codegen in Java tough me that it's not the thing you want to have around in any environment.
@@giorgospapadakis7613 what’s reflection? Noob here. I could just Google on it. Then reflect on it. Nah I think I know what it is but curious the benefits on this
I’ve always preferred the Dart Data Class VS Code extension
Edit: the author deleted the extension... however there are multiple reuploads
Indeed amazing time saving tool.
Good to know, I'll give it a try
Way better idea
I have the tutorial video in my channel
Thanks! I don't know how I could have missed such an extension..
It even works with Equatable package.
Sadly the package used to get rid of boilerplate requires quite a bit of boilerplate.. It also seems way less readable than most alternatives..
You're just listing your variables and add a few self-explanatory annotations. Not a lot of boilerplate in my book.
I personally use Freezed a lot and I can say that its nothing compared to the benefits it provides
@@vaibhavdangayachvd I also don't know what alternatives they are talking about other than not using Flutter at all 😅
I have not used freeze package before though....I always thought it's was way complicated than the problem it's was trying to solve.. However, thanks to this clip...I think I play round with it...
i have the same thing in mind.
Try its Out Its Also Provide Unions
@@dolbysoundsofficial9323 wow. Cool.
@@dolbysoundsofficial9323 Unions? does thst mean equality? like the Equatable package?
You have no idea how many people were waiting for this!!
We just can't thanks this beautiful community of flutter they are making so much valuable content today flutter release was amazing....
For me the biggest advantage of freezed wasnt even mentioned in this video. Freezed classes work like kotlin's sealed classes that allow for exhaustive case comparison. That really can fix bugs at compile time. Less debugging weird bugs, more happy coding.
I don't know why, but it's a little surprising that flutter introduces freezed.
Please go to the next door where Kotlin devs sit and ask them how to add Data classes. Thank you ❤️
Kotlin data class is so simple. Coming from Android, this seems too much to learn for a simple data class.
@@abhimanyu.n14 Dart feels like I was pushed back to Java . I miss Kotlin so much
Remi, we all love you :')
I prefer a vscode extension that generates everything instantly and without the need of any dependency
Does that exist?
me too pal
@@michasengotta2295 Data class Extension
That's the best solution. You don't wait build runner everytime. İt's time saver
What it your class changes?
I think Dart data class extension in Vs Code can be excellent alternative for freezed
Cool to see that Remi's work is being appreciated even by the Flutter team... way to go!!
Remi's Work is Great ✌️
Remi is a living legend. He inspires me.
The damn problem is that he doesn't get a penny from any of thise
Should we version control the generated classes?
Or I can simply install an extension like dart data class to generate these. Much easier than freeze i guess.
Could you please share the link?
@@kirill4531 similar extension is available for VS Code too if that's your preferred IDE
@@sampathnarayanan3229 do you happen to know if something similar is available for Android Studio?
@@kirill4531 Dart Data Class
"If you've come to Flutter in Dart by the way of other languages, you may have noticed that dart asks you to write a fair amount of boilerplate for simple classes"
You actually admits this and don't think its a problem?
We need discriminated unions and pattern matching in dart. These alone would remove the need for some much boilerplate and code generators.
Thank you flutter you guys really make the job simpler
Awesome, I was just thinking about this!! :D
what's the difference b/w dev_dependency and normal dependency? Anyone ?
It's still bad that you need to manually import the packages, and the fromJsom toJson methods instead of them working automatically.
Also the fact you need to manually tell it to build, and not it doing that whenever you rerun the app
You can issue this command only once `flutter packages pub run build_runner watch` and it will watch for changes in generation files and rebuild everything upon every save.
Please add data classes to dart natively
How about the setters?? freezed required factory consturctor so we can't extends that class and add setters and extra functionallity, I think those duplicated code should really dart core feature, dart data class like kotlin
Awesome. But still a boilerplate left on this solution. Data classes is far away a better solution for dart language
Hrmm looks like a lot of people here are pointing out that this is a more complicated of the data class extension, however don't take into account that freezed allows for sealed classes and unions which are essentially a language feature that dart is lacking
Still a fair criticism, it's ok just wanting data classes
I was just thinking of this today
So it is just a combination of json annotation , json serializable and equatable library?
No, it also adds sealed classes and unions, which are extremely powerful and yet to be added natively to dart
thanks..
Love it so much.
what happens when we give a variable on RHS of a factory constructor?
This is called a "redirecting constructor", and it means that all of the relevant implementation can be found within the class that appears on the RHS. In Freezed's case, this entire class definition is part of the code Freezed will generate for us :)
So much fuss just to work with data classes?
I think you should also talk about the limitations of using freezed, like not being able to use 'extends', because this may be a deal breaker in a lot of situations
Why can you not use 'extends' with it though?
@@michasengotta2295 I am not sure of why, but it clearly says in the documentation of freezed that it does not support inheritance. I also tried it anyways and it results in a lot of errors. Not sure of what caused this, since I don't know that much about the implementation details of freezed, but it is a thing.
@@wish8047 ok that sucks. Thanks for the heads up, I was about to use it, but now I'm not so sure..
This is Best Package i ever seen😘🔥
Great package saves a lot of time 🔥👍
Gracias ♥
It's a shame for Dart that it's not dynamic enough & we've to use third-party tools to "generate" extreme boilerplate code
Dart has so much to evolve.
Can we get an official package to make GIFs from video files? We need more utility!
Thanks for this amazing package Remi Rousselet 💙
So helpful!
Great package to know about. It is kinda same that we use with chopper.
great video as always but still a little confusing for me
Every package by Remi is amazing.
Amazing to see Freezed here
J'utilise déjà la classe gelée. c'est une classe incroyable. ça fait gagner beaucoup de temps ❤️❤️❤️
Ça sera compliqué de l'utiliser avec hive je crois
Sorry - yuck. I'll just continue to use my existing code templates and copy/paste.
Freeze!! Hammer Time!
Freezed is amazing and Flutter's UA-cam Channel is growing everyday more! 😄🔥
Can someone explain what problem this is solving?
This is a crutch for absent reflection.
@@koldoon3279 that confused me more than i was before lol
how to add late keyword to field declaration
I don't see any mention of this in Freezed's docs. While not exactly the same, you can always use `myObj.copyWith()` to set the "late" value, or you can use @unfreezed to use mutable classes instead.
Please add data classes and sealed classes to dart!!
You need a lot of boilerplate to avoid to write more boilerplate
I'm just tired of these generators
why?
Next package of the week: Riverpod
Nice and handy, but would it be better to name that package something more explanatory, something that refers to boilerplate code or whatever!!!
Still I will recommend to use general way... because it is more simple and less dependent...
Nice! Will be great for the app I am building rn
I already use freezed class. it is amazing class. it save a lot of time ❤️
YAHH ITS LIFE SAVING ...!!
👏
Ахаха ))) проще реализовать свои методы toMap fromMap ... Сделайте уже толковую рефлексию, чтоб вызывать методы по строке
i didnt get it, maybe because i have been into flutter for 2 months only
I thought use a plugin in android studio to generate my model is easier than this package. 😁
i'm alone ? I didn't like code gen
why?
@@keithbacalso9433 Boilerplate, heavy maintenance, hard to replace etc
This is not a solution. It should have @override methods in the ide to be autofilled
For those who wonder why is this required, i do the search and it's needed to keep the compiled binaries size as low as possible. Dart supports reflection but flutter doesn't.
Had no idea Dart supported reflection!
@freezed not @Freezed()
I missed the simple part!!!
Freezed 🥶
Why that emoji??
@@hamzabarry7880 cuz its freezed and I like it) nothing more. :)
This package solved my problems
In inelegant solution to a messy problem...
So simple isnt it ;P
Beta tester od roku 2016 oceňujem
4 dependencies, several annotations, command line tools and code generation. This implementation is tedious.. should have used kotlin honestly
I have no fn idea why they didn't use Kotlin as the default. It was sitting there ready to go. Already used on Android. Can't think of a single bennifit of selecting Dart over Kotlin. I wonder whose pet project Dart was?
I wish Flutter uses Kotlin instead of Dart, the world would be an happier place.
Are you high?
Rewriting 10 probably 20000 lines of code in a completely different language
Also how much more do you want of that JVM? Its hard to debug, super slow & has huge memory consumption
If a hybrid large framework flutter directly runs on this, it will just gonna ruin the native performance of flutter
If it used Python that would be awesome, but it would probably be too slow
Please stop, dart is perfect
Emir as bayrakları
boilerplate should generated from IDE plugins, instead this
I love the package Freezed, but man the build runner sucks
"If you've come to Flutter and Dart by way of other languages, you may have noticed that Dart asks you to write a fair amount of boilerplate for simple classes" 🤡🤡🤡🤡🤡🤡
How can you not see the idiocy here
The true problem is that no new language should have been designed this verbose
It is not that new. Anyway, we could get nice DSL written in Dart, but got hardcore general purpose OOP hell.
kotlin data class is way superior... will be very happy to see a native data class in dart
Use Dart Data Class Generator VS code extension to get rid of this package and headache. There is a video about the extension in my channel.
that's still a lot of boilerplate code... Lombok did much better in Java with just annotations...
Dart data class is better than Kotlin 🤣🤣🤣🤣🤣🤣
Why don't we call it Lombok? 😂
Still too cryptic, it's not as simple as Lombok
Seems better than built_value. Horrible name though. Isn't that wrong english?
It was that or "Let it goooo"
@@remirousselet6867 Let it go it is then! Better than a typo...
Code generation is a DISASTER! Especially this "don't pay the linter too much mind"... Welcome back to 1970 and a C-language! Are you seriously suggesting to write a code blindly in 2022? that's insane. Sorry, guys, you must find better way to do all those stuff and a good native language-level reflection API is the best step towards to solving this problem and away from all these crutches.
Seems more complicated, why not provide build in support out of the box. No wonder why people hate dart.
That would require refection which would make tree-shaking and small binaries impossible.
@@francisgeorge7639 true but this things need to consider before even they release dart from day one. I think dart introduce lots of issues including multithreading and isolate even if it is fairly new language. Look at kotlin, how beautiful language is data class,coroutine etc
P.S just saying
I've seen people argue that dart's flutter version (native dart has reflection) makes sense for front facing code. Seeing people complain of the web load speed could be argued either way: even with no reflection they couldn't get it small enough, or that it's still good enough as a web app even if too large for a web site.
@@francisgeorge7639 Bullshit. Lots of other languages and platforms solved this problem somehow and dart team also can, but this decision looks rather like some conflict with their ideology - I can't find another explanation.
@@koldoon3279 Why would I bullshit you? That's the explanation they have given themselves. And it makes sense to me.
Meh, a bit better I guess
@immutable
class Todo {
Todo(
this.description, {
this.completed = false,
String? id,
}) : id = id ?? _uuid.v4();
final String id;
final String description;
final bool completed;
}
How to achieve this?
Dart Data Plugin is more better. this package requires so many boilerplate codes and running build command.
sadly i don't like it a bit :/
ngefreez
Code generation kind of sucks though...
I hate this kind of solution so much.
Wayyyy to much of effort
Greek.
Nah thanks. Don't like freezed
Dart is great computer science but very ugly. Ugly never lasts. They should have made Flutter better to use than CSS/HTML/JS. It gets ugly by the day. Feels like they made this framework only to make it obsolete and then come up with something else.
So bad, I didn't love it at all. I don't recommend it
This is rubbish