Sealed Unions in Dart - Never Write an If Statement Again (Kind Of…)

แชร์
ฝัง
  • เผยแพร่เมื่อ 1 ก.พ. 2025

ความคิดเห็น • 54

  • @skoppisetti
    @skoppisetti 5 ปีที่แล้ว +7

    These video tutorials are absolutely hidden gems. I wish I discovered them sooner. Thank you.

  • @intelxd
    @intelxd 4 ปีที่แล้ว +14

    I was looking to something that could replace the cumbersome cluttered ifs that we all need sometimes, but this seems to be even more complicated than keeping my nested ifs. Great video though, congrats

    • @mohammedgt8102
      @mohammedgt8102 3 ปีที่แล้ว +5

      That's what I was thinking. Why replace easy to read code with harder to read code and a dependency on a package that will go out of date or have breaking changes at some point?

    • @MrTurbo_
      @MrTurbo_ 2 ปีที่แล้ว +2

      @@mohammedgt8102 good question, seems to be a trend in programming in general, using new packages to solve the same problems in a different way, just because it's different and new, not because it's better, it really annoys me

  • @codinginflow
    @codinginflow 5 ปีที่แล้ว +14

    Haha, there is a seal on the thumbnail because of SEALed classes 😂😁

    • @codinginflow
      @codinginflow 5 ปีที่แล้ว +6

      I SEAL what you did there

    • @ResoCoder
      @ResoCoder  5 ปีที่แล้ว +3

      That's right!

  • @valehasadli
    @valehasadli 4 ปีที่แล้ว +11

    My opinion is totally unnecessary complexity. Honestly I prefer following the KISS principle. I believe that if new developer doesn’t understand the first time that means that something gone wrong. Let’s summarize, I prefer keeping nested if statements instead of that complexity.
    Btw your tutorials are just amazing!

  • @Elite7555
    @Elite7555 3 ปีที่แล้ว +6

    5:37 Well, you could throw an Exception at that point. I think that would be best practice.

  • @chouaibsam4381
    @chouaibsam4381 2 ปีที่แล้ว

    I'm new to dart those codes are insane WTFFFFFFFFFFFF

  • @brylie
    @brylie ปีที่แล้ว

    Can you do a tutorial on Dart 3 sealed classes?

  • @2mvX
    @2mvX 2 ปีที่แล้ว

    I got this concept and thank you for explaining, however this code of state class looks like an absolute nightmare. Nice to know about this concept but I'll probably never use it

  • @MrKsuhiyp
    @MrKsuhiyp 4 ปีที่แล้ว

    Can't like this superb content anymore, perfectly done

  • @jonathanwhite2715
    @jonathanwhite2715 5 ปีที่แล้ว +9

    To be honest I got to 11:57 and then noped right out of there

    • @bartekpa
      @bartekpa 4 ปีที่แล้ว +4

      Same here. Dart is marketing itself as modern and expressive but tbh it looks like a cripple when compared to something truly modern, like Kotlin or Swift.

  • @faizgalimov
    @faizgalimov 2 ปีที่แล้ว

    Great explanation!

  • @yusufagboola5269
    @yusufagboola5269 3 ปีที่แล้ว

    @Reso coder can you do a video of testing block testing with sealed classes 🙏

  • @ramyakmehra312
    @ramyakmehra312 3 ปีที่แล้ว +1

    Freezed is a great alternative for this.

  • @rajatarora9139
    @rajatarora9139 5 ปีที่แล้ว

    Hi first of all, awesome video, I am just starting to flutter, I saw your playlist section but I am unable to find a playlist related to beginning with flutter, can you suggest me from which video to start and how to proceed.

  • @parvinderjitsingh5117
    @parvinderjitsingh5117 3 ปีที่แล้ว

    @dart: It feels u are working in obsolete language after working in swift or kotlin

  • @bartektartanus7197
    @bartektartanus7197 5 ปีที่แล้ว +2

    A lot of boilerplate in class definition. Maybe they will add sealed classes in dart language?

    • @ResoCoder
      @ResoCoder  5 ปีที่แล้ว +2

      It seems that the Dart team is currently gathering information regarding in which direction they should move with algebraic data types. github.com/dart-lang/language/issues/546

    • @guledali8902
      @guledali8902 5 ปีที่แล้ว

      Ey man Can you please make a video when it comes out
      I am new to programming in general so I am watching your videos so that my Subconscious brain Learns

  • @mohammedelfatih8018
    @mohammedelfatih8018 4 ปีที่แล้ว +2

    Hello Redo code, instead of all this, why not adding an abstract method called widgetBuilder to WeatherState, and so all subclasses are forced to implement it

    • @TekExplorer
      @TekExplorer 2 ปีที่แล้ว

      not useful, as you rarely show the same widget every time

  • @kaksisve4012
    @kaksisve4012 4 ปีที่แล้ว

    algebraic data types go brrrr

  • @MirzaMaulanapositivejutsu
    @MirzaMaulanapositivejutsu 11 หลายเดือนก่อน

    why don't you use pattern in flutter by using sealed class?

  • @Sdirimohamedsalah
    @Sdirimohamedsalah 4 ปีที่แล้ว

    Little bit confused.. how private class could be instated and initiated inside mother class ? Is this normal or a specifications in Dart ?

  • @BrendansReasons
    @BrendansReasons 3 ปีที่แล้ว

    Good video, thanks

  • @SEOTADEO
    @SEOTADEO 3 ปีที่แล้ว

    Good to know but I really dont like how this looks like. The superEnum you presented in another video felt much better!

  • @sercan.gundogdu
    @sercan.gundogdu 5 ปีที่แล้ว

    Which extention is that turning the ugly fat arrow to a lovely beautiful arrow?

    • @sercan.gundogdu
      @sercan.gundogdu 5 ปีที่แล้ว +1

      Nevermind, I found it in your extentions video. Install Fira Code font & enable font ligatures. Thanks.

  • @shredder2794
    @shredder2794 2 ปีที่แล้ว

    You can do this with the Freezed package now.

  • @pradeep422
    @pradeep422 5 ปีที่แล้ว

    I wish there's Sealed generator>>> gud tut!!!

    • @ResoCoder
      @ResoCoder  5 ปีที่แล้ว +1

      There actually is. I found out about it recently. Check out the sum_types package.

  • @alex_moreno
    @alex_moreno 4 ปีที่แล้ว

    Good tutorial as always but this library is not good at all compared with freezed...

  • @daviidon
    @daviidon 4 ปีที่แล้ว +1

    I prefer super enum, was less boilerplate.

  • @peekpt
    @peekpt 5 ปีที่แล้ว +4

    No way! 😅 But nice work

  • @fishslinger101
    @fishslinger101 5 ปีที่แล้ว +1

    So state.join takes positional parameters so it is possible to get this in the wrong order?

  • @officialismailshah
    @officialismailshah 3 ปีที่แล้ว

    there should have to snippet for this.. sealed unions

  • @eliashdez
    @eliashdez 5 ปีที่แล้ว

    What about pattern matching? That would be cleaner IMHO, but nor sure if the latest version of Dart supports it.

  • @Linxy
    @Linxy 5 ปีที่แล้ว +1

    boiletplate sphagetti

  • @narcodico
    @narcodico 5 ปีที่แล้ว +3

    You could just as easily forget to add in one of those private classes, just saying.

  • @amaromem1
    @amaromem1 5 ปีที่แล้ว

    Is there something we can do about Data Science using Android/Flutter/Swift ?
    I'd like to know

  • @FrancisWagner
    @FrancisWagner 2 ปีที่แล้ว

    Great video, but now the code has added a great amount of unnecessary complexity. It seems no point in using it at all.

  • @AbdolHussain
    @AbdolHussain 5 ปีที่แล้ว

    I need to play video in 1.25 playback speed 😂

  • @ntirinigasenior7901
    @ntirinigasenior7901 5 ปีที่แล้ว +1

    new package called sealed_flutter_bloc, check it out

  • @ABHISHEK-jc8kn
    @ABHISHEK-jc8kn 2 ปีที่แล้ว

    Or just use freezed like an ordinary programmer. No live template bullshit for this boilerplate

  • @greatsaid5271
    @greatsaid5271 5 ปีที่แล้ว

    what is the benefit of it?

  • @whitebai6367
    @whitebai6367 3 ปีที่แล้ว

    wow, God, I'd rather us 'if else'

  • @rohankumarpanigrahi7475
    @rohankumarpanigrahi7475 ปีที่แล้ว

    Unnecessary complexity tbh