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;
  • Наука та технологія

КОМЕНТАРІ • 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 роки тому +280

    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

    • @giorgospapadakis7613
      @giorgospapadakis7613 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 Рік тому

      @@giorgospapadakis7613 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 Рік тому

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

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

  • @patibandasriram7613
    @patibandasriram7613 2 роки тому +3

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

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

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

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

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

  • @ilyosbekibrokhimov5266
    @ilyosbekibrokhimov5266 2 роки тому +12

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

  • @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 8 місяців тому +1

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

  • @imrahil008
    @imrahil008 2 роки тому

    Should we version control the generated classes?

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

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

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

  • @joeyreddick6036
    @joeyreddick6036 2 роки тому +4

    Thank you flutter you guys really make the job simpler

  • @cardboard3161
    @cardboard3161 2 роки тому

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

  • @faizandarwesh7867
    @faizandarwesh7867 2 роки тому

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

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

  • @sharbelokzan9673
    @sharbelokzan9673 2 роки тому +9

    Please add data classes to dart natively

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

  • @bdmaxvalera
    @bdmaxvalera 2 роки тому +9

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

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

  • @randomlee101
    @randomlee101 2 роки тому +2

    I was just thinking of this today

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

  • @RamdanCode
    @RamdanCode 2 роки тому +2

    thanks..
    Love it so much.

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

  • @TheHellishFrog
    @TheHellishFrog 2 роки тому +3

    So much fuss just to work with data classes?

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

  • @dolbysoundsofficial9323
    @dolbysoundsofficial9323 2 роки тому

    This is Best Package i ever seen😘🔥

  • @devbathani8020
    @devbathani8020 2 роки тому +8

    Great package saves a lot of time 🔥👍

  • @__renesan
    @__renesan 2 роки тому +1

    Gracias ♥

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

  • @kafran
    @kafran 2 роки тому +1

    Dart has so much to evolve.

  • @RightNow978
    @RightNow978 2 роки тому

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

  • @its_me_mahmud
    @its_me_mahmud 2 роки тому +6

    Thanks for this amazing package Remi Rousselet 💙

  • @erlangparasu7524
    @erlangparasu7524 Рік тому

    So helpful!

  • @PurvikRana
    @PurvikRana 2 роки тому +4

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

  • @galihriskipratama3631
    @galihriskipratama3631 2 роки тому +2

    great video as always but still a little confusing for me

  • @sangamshrestha143
    @sangamshrestha143 2 роки тому +3

    Every package by Remi is amazing.

  • @harinandanrnair6768
    @harinandanrnair6768 2 роки тому +2

    Amazing to see Freezed here

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

  • @AaronPritzlaff
    @AaronPritzlaff 2 роки тому +8

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

  • @hboleto
    @hboleto 2 роки тому

    Freeze!! Hammer Time!

  • @Aspiiire
    @Aspiiire 2 роки тому +15

    Freezed is amazing and Flutter's UA-cam Channel is growing everyday more! 😄🔥

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

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

  • @sanketnaik2082
    @sanketnaik2082 2 роки тому

    Please add data classes and sealed classes to dart!!

  • @ping411
    @ping411 Місяць тому +1

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

  • @iGhostr
    @iGhostr 2 роки тому +13

    I'm just tired of these generators

  • @michaeledano8067
    @michaeledano8067 2 роки тому +2

    Next package of the week: Riverpod

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

  • @muhammadanas7502
    @muhammadanas7502 2 роки тому +5

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

  • @HermanPalmgren
    @HermanPalmgren 2 роки тому

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

  • @sunilgrewal9043
    @sunilgrewal9043 2 роки тому +6

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

  • @hsnham6020
    @hsnham6020 2 роки тому +2

    👏

  • @user-pz1ce7on4x
    @user-pz1ce7on4x 2 роки тому +3

    Ахаха ))) проще реализовать свои методы toMap fromMap ... Сделайте уже толковую рефлексию, чтоб вызывать методы по строке

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

  • @blablablabla29382
    @blablablabla29382 2 роки тому +7

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

  • @blackhatvisions
    @blackhatvisions 2 роки тому

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

  • @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 11 місяців тому

      Had no idea Dart supported reflection!

  • @evgeniykalaganov6753
    @evgeniykalaganov6753 2 роки тому +1

    @freezed not @Freezed()

  • @samippaudel266
    @samippaudel266 2 роки тому +1

    I missed the simple part!!!

  • @mqhamdam
    @mqhamdam 2 роки тому +1

    Freezed 🥶

    • @hamzabarry7880
      @hamzabarry7880 2 роки тому

      Why that emoji??

    • @mqhamdam
      @mqhamdam 2 роки тому

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

  • @nickf2k_flutter
    @nickf2k_flutter 2 роки тому +1

    This package solved my problems

  • @amicloud_yt
    @amicloud_yt Рік тому +1

    In inelegant solution to a messy problem...

  • @jascodes
    @jascodes 2 роки тому +2

    So simple isnt it ;P

  • @jansprlak110
    @jansprlak110 2 роки тому +1

    Beta tester od roku 2016 oceňujem

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

  • @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 29 днів тому

      Please stop, dart is perfect

  • @erkinkurt6799
    @erkinkurt6799 2 роки тому +2

    Emir as bayrakları

  • @myxzlabs5635
    @myxzlabs5635 2 роки тому

    boilerplate should generated from IDE plugins, instead this

  • @patrickvieira9200
    @patrickvieira9200 Рік тому

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

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

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

  • @Mohamedka5116
    @Mohamedka5116 2 роки тому +2

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

  • @nawshadhamid1266
    @nawshadhamid1266 2 місяці тому +1

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

  • @ben6
    @ben6 2 роки тому

    Why don't we call it Lombok? 😂

  • @muhammedozdogan5133
    @muhammedozdogan5133 8 місяців тому

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

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

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

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

  • @5erTurbo
    @5erTurbo 2 роки тому +1

    Meh, a bit better I guess

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

  • @Mh-wn6ne
    @Mh-wn6ne 3 місяці тому

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

  • @moazahmed5388
    @moazahmed5388 2 роки тому +1

    sadly i don't like it a bit :/

  • @thekingssage4652
    @thekingssage4652 2 роки тому

    ngefreez

  • @BugGenerat0r
    @BugGenerat0r 2 роки тому

    Code generation kind of sucks though...

  • @julius4858
    @julius4858 Рік тому

    I hate this kind of solution so much.

  • @laujimmy9282
    @laujimmy9282 2 роки тому

    Wayyyy to much of effort

  • @cholasimmons
    @cholasimmons 2 роки тому +2

    Greek.

  • @thecodeninjaeu
    @thecodeninjaeu 2 роки тому

    Nah thanks. Don't like freezed

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

  • @asoftraiden
    @asoftraiden 2 роки тому

    This is rubbish