Freezed (Package of the Week)

Поделиться
HTML-код
  • Опубликовано: 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;
  • НаукаНаука

Комментарии • 183

  • @Sominemo
    @Sominemo 2 года назад +360

    Nice, but would be good for Dart to actually implement data classes

    • @SAPierce2006
      @SAPierce2006 2 года назад +34

      Code generation in dart is janky and terrible. It's not the same as language features.

    • @ebelevics
      @ebelevics 2 года назад +48

      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

    • @kirill4531
      @kirill4531 2 года назад +7

      Sometimes code generation takes too much time

    • @CagatayOncul
      @CagatayOncul 2 года назад +15

      Code gen is fully headache

    • @FlutterInsights
      @FlutterInsights 2 года назад +5

      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
      .

  • @SunFoxx_
    @SunFoxx_ 2 года назад +281

    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

    • @geor.papadakis
      @geor.papadakis 2 года назад +13

      the answer is reflection but flutter will never support that

    • @fuadall8961
      @fuadall8961 2 года назад +9

      Totally agreed. Sad to see that instead offering stable solutions Google team offers such ugly unprofessional hacks

    • @julius4858
      @julius4858 Год назад

      @@geor.papadakis may I ask why it will never happen?

    • @MegaLittlePaw
      @MegaLittlePaw Год назад +1

      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.

    • @maskedvillainai
      @maskedvillainai Год назад

      @@geor.papadakis 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

  • @BooleanDev
    @BooleanDev 2 года назад +101

    I’ve always preferred the Dart Data Class VS Code extension
    Edit: the author deleted the extension... however there are multiple reuploads

    •  2 года назад +4

      Indeed amazing time saving tool.

    • @marlonsubuyu2012
      @marlonsubuyu2012 2 года назад

      Good to know, I'll give it a try

    • @sajithlaldev3354
      @sajithlaldev3354 2 года назад

      Way better idea

    • @sajithlaldev3354
      @sajithlaldev3354 2 года назад

      I have the tutorial video in my channel

    • @atmega3212
      @atmega3212 2 года назад

      Thanks! I don't know how I could have missed such an extension..
      It even works with Equatable package.

  • @Masus04
    @Masus04 2 года назад +90

    Sadly the package used to get rid of boilerplate requires quite a bit of boilerplate.. It also seems way less readable than most alternatives..

    • @michasengotta2295
      @michasengotta2295 2 года назад +2

      You're just listing your variables and add a few self-explanatory annotations. Not a lot of boilerplate in my book.

    • @vaibhavdangayachvd
      @vaibhavdangayachvd 2 года назад +6

      I personally use Freezed a lot and I can say that its nothing compared to the benefits it provides

    • @michasengotta2295
      @michasengotta2295 2 года назад +4

      @@vaibhavdangayachvd I also don't know what alternatives they are talking about other than not using Flutter at all 😅

  • @ezeaguprincewill7005
    @ezeaguprincewill7005 2 года назад +71

    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...

  • @officialismailshah
    @officialismailshah 2 года назад +7

    We just can't thanks this beautiful community of flutter they are making so much valuable content today flutter release was amazing....

  • @patibandasriram7613
    @patibandasriram7613 2 года назад +3

    You have no idea how many people were waiting for this!!

  • @schinsky6833
    @schinsky6833 2 года назад +12

    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.

  • @user-pk6wi5ed4g
    @user-pk6wi5ed4g 2 года назад +9

    I don't know why, but it's a little surprising that flutter introduces freezed.

  • @rcjuancarlosuwu
    @rcjuancarlosuwu 2 года назад +10

    Remi, we all love you :')

  • @wdestroier
    @wdestroier 2 года назад +55

    I prefer a vscode extension that generates everything instantly and without the need of any dependency

  • @daviidon
    @daviidon 2 года назад +20

    We need discriminated unions and pattern matching in dart. These alone would remove the need for some much boilerplate and code generators.

  • @kirill4531
    @kirill4531 2 года назад +31

    Please go to the next door where Kotlin devs sit and ask them how to add Data classes. Thank you ❤️

    • @abhimanyu.n14
      @abhimanyu.n14 2 года назад +4

      Kotlin data class is so simple. Coming from Android, this seems too much to learn for a simple data class.

    • @walrider7374
      @walrider7374 Год назад

      @@abhimanyu.n14 Dart feels like I was pushed back to Java . I miss Kotlin so much

  • @sampathnarayanan3229
    @sampathnarayanan3229 2 года назад +22

    Or I can simply install an extension like dart data class to generate these. Much easier than freeze i guess.

    • @kirill4531
      @kirill4531 2 года назад +1

      Could you please share the link?

    • @sampathnarayanan3229
      @sampathnarayanan3229 2 года назад +4

      @@kirill4531 similar extension is available for VS Code too if that's your preferred IDE

    • @kirill4531
      @kirill4531 2 года назад +5

      @@sampathnarayanan3229 do you happen to know if something similar is available for Android Studio?

    • @user-pt5he1yq9n
      @user-pt5he1yq9n 2 года назад +1

      @@kirill4531 Dart Data Class

  • @joeyreddick6036
    @joeyreddick6036 2 года назад +4

    Thank you flutter you guys really make the job simpler

  • @venir_dev
    @venir_dev 2 года назад +32

    Cool to see that Remi's work is being appreciated even by the Flutter team... way to go!!

    • @dolbysoundsofficial9323
      @dolbysoundsofficial9323 2 года назад +2

      Remi's Work is Great ✌️

    • @aadarsh8869
      @aadarsh8869 2 года назад

      Remi is a living legend. He inspires me.

    • @Yayaloy9
      @Yayaloy9 9 месяцев назад +1

      The damn problem is that he doesn't get a penny from any of thise

  • @ilyosbekibrokhimov5266
    @ilyosbekibrokhimov5266 2 года назад +12

    I think Dart data class extension in Vs Code can be excellent alternative for freezed

  • @RamdanCode
    @RamdanCode 2 года назад +2

    thanks..
    Love it so much.

  • @bdmaxvalera
    @bdmaxvalera 2 года назад +9

    Awesome. But still a boilerplate left on this solution. Data classes is far away a better solution for dart language

  • @AhmadSattout97
    @AhmadSattout97 2 года назад +14

    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

    • @sokr5903
      @sokr5903 2 года назад +3

      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.

  • @mikkelthygesen3856
    @mikkelthygesen3856 2 года назад +7

    "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?

  • @cardboard3161
    @cardboard3161 2 года назад

    Awesome, I was just thinking about this!! :D

  • @dolbysoundsofficial9323
    @dolbysoundsofficial9323 2 года назад

    This is Best Package i ever seen😘🔥

  • @randomlee101
    @randomlee101 2 года назад +2

    I was just thinking of this today

  • @johnnynguyen6909
    @johnnynguyen6909 2 года назад +4

    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

    • @leandroamarillo3262
      @leandroamarillo3262 2 года назад +1

      Still a fair criticism, it's ok just wanting data classes

  • @devbathani8020
    @devbathani8020 2 года назад +8

    Great package saves a lot of time 🔥👍

  • @sharbelokzan9673
    @sharbelokzan9673 2 года назад +9

    Please add data classes to dart natively

  • @its_me_mahmud
    @its_me_mahmud 2 года назад +6

    Thanks for this amazing package Remi Rousselet 💙

  • @__renesan
    @__renesan 2 года назад +1

    Gracias ♥

  • @erlangparasu7524
    @erlangparasu7524 Год назад

    So helpful!

  • @PurvikRana
    @PurvikRana 2 года назад +4

    Great package to know about. It is kinda same that we use with chopper.

  • @imrahil008
    @imrahil008 2 года назад

    Should we version control the generated classes?

  • @krtirtho
    @krtirtho 2 года назад +6

    It's a shame for Dart that it's not dynamic enough & we've to use third-party tools to "generate" extreme boilerplate code

  • @wish8047
    @wish8047 2 года назад +5

    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

    • @michasengotta2295
      @michasengotta2295 2 года назад

      Why can you not use 'extends' with it though?

    • @wish8047
      @wish8047 2 года назад +5

      @@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.

    • @michasengotta2295
      @michasengotta2295 2 года назад +1

      @@wish8047 ok that sucks. Thanks for the heads up, I was about to use it, but now I'm not so sure..

  • @sangamshrestha143
    @sangamshrestha143 2 года назад +3

    Every package by Remi is amazing.

  • @kafran
    @kafran 2 года назад +1

    Dart has so much to evolve.

  • @freshtechtips
    @freshtechtips Год назад +1

    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

  • @TarY_
    @TarY_ 2 года назад +2

    J'utilise déjà la classe gelée. c'est une classe incroyable. ça fait gagner beaucoup de temps ❤️❤️❤️

    • @melomanzer5508
      @melomanzer5508 2 года назад

      Ça sera compliqué de l'utiliser avec hive je crois

  • @harinandanrnair6768
    @harinandanrnair6768 2 года назад +2

    Amazing to see Freezed here

  • @hboleto
    @hboleto 2 года назад

    Freeze!! Hammer Time!

  • @Aspiiire
    @Aspiiire 2 года назад +15

    Freezed is amazing and Flutter's RUclips Channel is growing everyday more! 😄🔥

  • @faizandarwesh7867
    @faizandarwesh7867 2 года назад

    what's the difference b/w dev_dependency and normal dependency? Anyone ?

  • @balajir9393
    @balajir9393 2 года назад +1

    So it is just a combination of json annotation , json serializable and equatable library?

    • @johnnynguyen6909
      @johnnynguyen6909 2 года назад +3

      No, it also adds sealed classes and unions, which are extremely powerful and yet to be added natively to dart

  • @galihriskipratama3631
    @galihriskipratama3631 2 года назад +2

    great video as always but still a little confusing for me

  • @RightNow978
    @RightNow978 2 года назад

    Can we get an official package to make GIFs from video files? We need more utility!

  • @anandhu5082
    @anandhu5082 2 года назад +1

    what happens when we give a variable on RHS of a factory constructor?

    • @craiglabenz9147
      @craiglabenz9147 2 года назад

      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 :)

  • @sunilgrewal9043
    @sunilgrewal9043 2 года назад +6

    I already use freezed class. it is amazing class. it save a lot of time ❤️

  • @michaeledano8067
    @michaeledano8067 2 года назад +2

    Next package of the week: Riverpod

  • @AaronPritzlaff
    @AaronPritzlaff 2 года назад +8

    Sorry - yuck. I'll just continue to use my existing code templates and copy/paste.

  • @HermanPalmgren
    @HermanPalmgren 2 года назад

    Nice! Will be great for the app I am building rn

  • @TheHellishFrog
    @TheHellishFrog 2 года назад +3

    So much fuss just to work with data classes?

  • @sanketnaik2082
    @sanketnaik2082 2 года назад

    Please add data classes and sealed classes to dart!!

  • @hsnham6020
    @hsnham6020 2 года назад +2

    👏

  • @iGhostr
    @iGhostr 2 года назад +14

    I'm just tired of these generators

    • @keithbacalso9433
      @keithbacalso9433 2 года назад

      why?

    • @user-ji2yk7wu4n
      @user-ji2yk7wu4n 7 дней назад

      ​@@keithbacalso9433because those features are suppose to be built-in in the language itself

  • @muhammadanas7502
    @muhammadanas7502 2 года назад +5

    Still I will recommend to use general way... because it is more simple and less dependent...

  • @mqhamdam
    @mqhamdam 2 года назад +1

    Freezed 🥶

    • @hamzabarry7880
      @hamzabarry7880 2 года назад

      Why that emoji??

    • @mqhamdam
      @mqhamdam 2 года назад

      @@hamzabarry7880 cuz its freezed and I like it) nothing more. :)

  • @kevinlopez287
    @kevinlopez287 2 года назад +2

    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.

    • @mikopiko
      @mikopiko Год назад

      Had no idea Dart supported reflection!

  • @mohanpreetsingh716
    @mohanpreetsingh716 2 года назад +1

    Can someone explain what problem this is solving?

    • @koldoon3279
      @koldoon3279 2 года назад +1

      This is a crutch for absent reflection.

    • @mohanpreetsingh716
      @mohanpreetsingh716 2 года назад

      @@koldoon3279 that confused me more than i was before lol

  • @thefable2874
    @thefable2874 2 года назад +2

    Nice and handy, but would it be better to name that package something more explanatory, something that refers to boilerplate code or whatever!!!

  • @amicloud_yt
    @amicloud_yt Год назад +1

    In inelegant solution to a messy problem...

  • @ping411
    @ping411 Месяц назад +1

    You need a lot of boilerplate to avoid to write more boilerplate

  • @jascodes
    @jascodes 2 года назад +2

    So simple isnt it ;P

  • @blablablabla29382
    @blablablabla29382 2 года назад +7

    i'm alone ? I didn't like code gen

  • @findsarfaraz
    @findsarfaraz 2 года назад

    how to add late keyword to field declaration

    • @craiglabenz9147
      @craiglabenz9147 2 года назад +1

      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.

  • @nickf2k_flutter
    @nickf2k_flutter 2 года назад +1

    This package solved my problems

  • @TheMikkelet
    @TheMikkelet 2 года назад +2

    4 dependencies, several annotations, command line tools and code generation. This implementation is tedious.. should have used kotlin honestly

    • @jonstorchevoy6087
      @jonstorchevoy6087 2 года назад

      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?

  • @evgeniykalaganov6753
    @evgeniykalaganov6753 2 года назад +1

    @freezed not @Freezed()

  • @erkinkurt6799
    @erkinkurt6799 2 года назад +2

    Emir as bayrakları

  • @blackhatvisions
    @blackhatvisions 2 года назад

    This is not a solution. It should have @override methods in the ide to be autofilled

  • @ramsay9912
    @ramsay9912 Год назад

    i didnt get it, maybe because i have been into flutter for 2 months only

  • @habibulumam9395
    @habibulumam9395 2 года назад

    I thought use a plugin in android studio to generate my model is easier than this package. 😁

  • @samippaudel266
    @samippaudel266 2 года назад +1

    I missed the simple part!!!

  • @jansprlak110
    @jansprlak110 2 года назад +1

    Beta tester od roku 2016 oceňujem

  • @Nyao35
    @Nyao35 2 года назад +15

    I wish Flutter uses Kotlin instead of Dart, the world would be an happier place.

    • @krtirtho
      @krtirtho 2 года назад +2

      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

    • @tylerpetrov8094
      @tylerpetrov8094 Год назад

      If it used Python that would be awesome, but it would probably be too slow

    • @BottropBoy
      @BottropBoy Месяц назад

      Please stop, dart is perfect

  • @Mohamedka5116
    @Mohamedka5116 2 года назад +2

    that's still a lot of boilerplate code... Lombok did much better in Java with just annotations...

  • @nawshadhamid1266
    @nawshadhamid1266 3 месяца назад +1

    Dart data class is better than Kotlin 🤣🤣🤣🤣🤣🤣

  • @StephenRoseDuo
    @StephenRoseDuo 2 года назад +16

    The true problem is that no new language should have been designed this verbose

    • @neuzen
      @neuzen 2 года назад

      It is not that new. Anyway, we could get nice DSL written in Dart, but got hardcore general purpose OOP hell.

  • @muntasirmahmudsaif6239
    @muntasirmahmudsaif6239 2 года назад

    kotlin data class is way superior... will be very happy to see a native data class in dart

    • @sajithlaldev3354
      @sajithlaldev3354 2 года назад

      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.

  • @patrickvieira9200
    @patrickvieira9200 Год назад

    I love the package Freezed, but man the build runner sucks

  • @kharagkunchok
    @kharagkunchok 2 года назад +20

    Seems more complicated, why not provide build in support out of the box. No wonder why people hate dart.

    • @francisgeorge7639
      @francisgeorge7639 2 года назад

      That would require refection which would make tree-shaking and small binaries impossible.

    • @kharagkunchok
      @kharagkunchok 2 года назад

      @@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

    • @francisgeorge7639
      @francisgeorge7639 2 года назад +1

      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.

    • @koldoon3279
      @koldoon3279 2 года назад

      @@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.

    • @francisgeorge7639
      @francisgeorge7639 2 года назад

      @@koldoon3279 Why would I bullshit you? That's the explanation they have given themselves. And it makes sense to me.

  • @danvilela
    @danvilela 2 года назад +1

    Seems better than built_value. Horrible name though. Isn't that wrong english?

    • @remirousselet6867
      @remirousselet6867 2 года назад +1

      It was that or "Let it goooo"

    • @danvilela
      @danvilela Год назад

      @@remirousselet6867 Let it go it is then! Better than a typo...

  • @TheMikkelet
    @TheMikkelet Год назад +1

    "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

  • @myxzlabs5635
    @myxzlabs5635 2 года назад

    boilerplate should generated from IDE plugins, instead this

  • @thekingssage4652
    @thekingssage4652 2 года назад

    ngefreez

  • @muhammedozdogan5133
    @muhammedozdogan5133 8 месяцев назад

    Still too cryptic, it's not as simple as Lombok

  • @koldoon3279
    @koldoon3279 2 года назад +3

    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.

  • @ben6
    @ben6 2 года назад

    Why don't we call it Lombok? 😂

  • @5erTurbo
    @5erTurbo 2 года назад +1

    Meh, a bit better I guess

  • @moazahmed5388
    @moazahmed5388 2 года назад +1

    sadly i don't like it a bit :/

  • @Mh-wn6ne
    @Mh-wn6ne 3 месяца назад

    Dart Data Plugin is more better. this package requires so many boilerplate codes and running build command.

  • @BugGenerat0r
    @BugGenerat0r 2 года назад

    Code generation kind of sucks though...

  • @julius4858
    @julius4858 Год назад

    I hate this kind of solution so much.

  • @cholasimmons
    @cholasimmons 2 года назад +2

    Greek.

  • @laujimmy9282
    @laujimmy9282 2 года назад

    Wayyyy to much of effort

  • @thecodeninjaeu
    @thecodeninjaeu 2 года назад

    Nah thanks. Don't like freezed

  • @asoftraiden
    @asoftraiden 2 года назад

    This is rubbish

  • @brahm-ahamasmi
    @brahm-ahamasmi Год назад

    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.

  • @mustafaabozaina2787
    @mustafaabozaina2787 2 года назад

    So bad, I didn't love it at all. I don't recommend it

  • @pratapkhandekar8322
    @pratapkhandekar8322 2 года назад +1

    React native is 100times easy than flutter

  • @findsarfaraz
    @findsarfaraz Год назад

    @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?