Тёмный
No video :(

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

Reso Coder
Подписаться 113 тыс.
Просмотров 18 тыс.
50% 1

📗 Learn from the written tutorial 👇👇
resocoder.com/...
👨‍💻 Do you write good code? Find out now!
resocoder.com/...
The 'is' operator is a powerful thing. Checking for a subtype of an object is used in many areas, for example in state management with BLoC or Redux. Think about all those events and states. How many times have you forgotten to check for a particular type in an if or a switch statement? There is simply no way, outside of juggling all those different classes in your head, to make sure that every type is being checked for.
Not anymore! There actually is a way to make you never forget about checking for a certain type. While many other languages have this feature built into them (come on Dart!), for us, Dart developers there is a package for it - sealed_unions.
Go to my website for more information, code examples, and articles:
● resocoder.com
Follow me on social media:
● / resocoder
● / resocoder
● / resocoder

Опубликовано:

 

26 авг 2024

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 54   
@skoppisetti
@skoppisetti 4 года назад
These video tutorials are absolutely hidden gems. I wish I discovered them sooner. Thank you.
@valehasadli
@valehasadli 3 года назад
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!
@intelxd
@intelxd 4 года назад
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 2 года назад
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 года назад
@@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 лет назад
Haha, there is a seal on the thumbnail because of SEALed classes 😂😁
@codinginflow
@codinginflow 5 лет назад
I SEAL what you did there
@ResoCoder
@ResoCoder 5 лет назад
That's right!
@Elite7555
@Elite7555 3 года назад
5:37 Well, you could throw an Exception at that point. I think that would be best practice.
@jonathanwhite2715
@jonathanwhite2715 4 года назад
To be honest I got to 11:57 and then noped right out of there
@bartekpacia
@bartekpacia 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.
@chouaibsam4381
@chouaibsam4381 2 года назад
I'm new to dart those codes are insane WTFFFFFFFFFFFF
@faizgalimov
@faizgalimov 2 года назад
Great explanation!
@brylie
@brylie 11 месяцев назад
Can you do a tutorial on Dart 3 sealed classes?
@MrKsuhiyp
@MrKsuhiyp 4 года назад
Can't like this superb content anymore, perfectly done
@ramyakmehra312
@ramyakmehra312 3 года назад
Freezed is a great alternative for this.
@2mvX
@2mvX Год назад
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
@kaksisve4012
@kaksisve4012 3 года назад
algebraic data types go brrrr
@yusufagboola5269
@yusufagboola5269 2 года назад
@Reso coder can you do a video of testing block testing with sealed classes 🙏
@mohammedelfatih8018
@mohammedelfatih8018 4 года назад
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 Год назад
not useful, as you rarely show the same widget every time
@BrendansReasons
@BrendansReasons 2 года назад
Good video, thanks
@rajatarora9139
@rajatarora9139 4 года назад
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.
@SEOTADEO
@SEOTADEO 2 года назад
Good to know but I really dont like how this looks like. The superEnum you presented in another video felt much better!
@bartektartanus7197
@bartektartanus7197 5 лет назад
A lot of boilerplate in class definition. Maybe they will add sealed classes in dart language?
@ResoCoder
@ResoCoder 5 лет назад
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 4 года назад
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
@MirzaMaulanapositivejutsu
@MirzaMaulanapositivejutsu 6 месяцев назад
why don't you use pattern in flutter by using sealed class?
@shredder2794
@shredder2794 2 года назад
You can do this with the Freezed package now.
@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 ?
@officialismailshah
@officialismailshah 2 года назад
there should have to snippet for this.. sealed unions
@parvinderjitsingh5117
@parvinderjitsingh5117 3 года назад
@dart: It feels u are working in obsolete language after working in swift or kotlin
@daviidon
@daviidon 4 года назад
I prefer super enum, was less boilerplate.
@pradeep422
@pradeep422 5 лет назад
I wish there's Sealed generator>>> gud tut!!!
@ResoCoder
@ResoCoder 5 лет назад
There actually is. I found out about it recently. Check out the sum_types package.
@Linxy
@Linxy 4 года назад
boiletplate sphagetti
@peekpt
@peekpt 5 лет назад
No way! 😅 But nice work
@salonumuzklimalidir
@salonumuzklimalidir 4 года назад
Which extention is that turning the ugly fat arrow to a lovely beautiful arrow?
@salonumuzklimalidir
@salonumuzklimalidir 4 года назад
Nevermind, I found it in your extentions video. Install Fira Code font & enable font ligatures. Thanks.
@fishslinger101
@fishslinger101 4 года назад
So state.join takes positional parameters so it is possible to get this in the wrong order?
@alex_moreno
@alex_moreno 4 года назад
Good tutorial as always but this library is not good at all compared with freezed...
@narcodico
@narcodico 5 лет назад
You could just as easily forget to add in one of those private classes, just saying.
@vladimirbobyr2217
@vladimirbobyr2217 4 года назад
Rolly Peres but it's a single place
@ntirinigasenior7901
@ntirinigasenior7901 5 лет назад
new package called sealed_flutter_bloc, check it out
@eliashdez
@eliashdez 5 лет назад
What about pattern matching? That would be cleaner IMHO, but nor sure if the latest version of Dart supports it.
@amaromem1
@amaromem1 5 лет назад
Is there something we can do about Data Science using Android/Flutter/Swift ? I'd like to know
@greatsaid5271
@greatsaid5271 5 лет назад
what is the benefit of it?
@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.
@ABHISHEK-jc8kn
@ABHISHEK-jc8kn Год назад
Or just use freezed like an ordinary programmer. No live template bullshit for this boilerplate
@AbdolHussain
@AbdolHussain 5 лет назад
I need to play video in 1.25 playback speed 😂
@whitebai6367
@whitebai6367 3 года назад
wow, God, I'd rather us 'if else'
@rohankumarpanigrahi7475
@rohankumarpanigrahi7475 Год назад
Unnecessary complexity tbh
Далее
skibidi toilet multiverse 041
06:01
Просмотров 5 млн
Bloc Library - Painless State Management for Flutter
24:54
Bringing pattern matching to Dart
20:28
Просмотров 38 тыс.
It's time for change, it's time for Linux.
10:53
Просмотров 219 тыс.
Flutter Bloc & Cubit Tutorial
47:58
Просмотров 121 тыс.
The Surgery That Proved There Is No Free Will
29:43
Просмотров 268 тыс.
What's New in Dart 3?
30:09
Просмотров 28 тыс.