Super Enum 💪 Dart & Flutter Tutorial – Store Custom Data

preview_player
Показать описание
📗 Learn from the written tutorial 👇👇

🎯 The biggest Flutter conference in Europe:

📧 Get Flutter news 📰 and resources:

👨‍💻 Do you write good code? Find out now!

Enumerated types in Dart have always been not so useful, compared to other languages. You cannot store additional data in them and using the regular switch statement is a pain. However, when you use a package called super_enum, you can bring a bit of the enum glory to Dart over from Kotlin.

In this tutorial, you're going to learn about super_enum in Flutter by building states and events for a BLoC used for displaying weather forecast. It's OK if you're not at home with BLoC - we're not going to touch it much. Of course, you can use this package in any Dart project and for any occasion.

Go to my website for more information, code examples, and articles:

Follow me on social media:
Рекомендации по теме
Комментарии
Автор

Proud that my teammates created this package - Sahil and Jai

shubhamjain
Автор

Thanks Reso for doing this awesome tutorial and showing various use case of super_enum.

SahilKumar-oiuq
Автор

Best tutorials I have seen. A+ just cool, thx

ridesun
Автор

Awesome! Way better than that much boilerplate.. Can built_value (which has enum classes) be used to this too and replace also equatable?

danvilela
Автор

Very useful tutorial keep it coming! 😍

ianjaspersantos
Автор

I am definitely going to ues these packages..

pathakvivek
Автор

after updates on bloc and superenum, generated files are on the top level, so weather_bloc.g.dart should be generated instead of weather_event.g.dart. So in the ui, while writing bloc listener I tried } and it seems worked. :) Thanks for great vid.

mkroven
Автор

thanks. I have a question
assume I have 6 or more bloc or qubit in my flutter project
and all of them have 3 state(loading, error, success) but success of each bloc are different arguments
now what is best practice for implementing this. use multi bloc state file with exactly same structure and a little different success argument or is there any better option for reduce boiler plate code?

parsamaghsoodi
Автор

Hello Reso Coder, what shall we do in the case we want to pass a List<SomeEntity> as the DataField? You can only use the 'List' class but not 'List<SomeEntity'. Is there something we can do other than have to wrap the SomeEntity in a 'SomeEntityList' class?

eliasavelino
Автор

ResoCoder Help! Its not possible to yield* superEnum.when(..., ...); inside the bloc after the new version. What can we do now?

Linxy
Автор

These 2 dislikes: first one was just a guy with big big fingers, the other one was that same guy really trying to hit like 😁

oblakus
Автор

I faced an issue using this approach, the problem that when yielding a new state the previous one gets replaced completely and its data gets lost, is there a way to overcome this problem. And thanks for your valuable courses that we learnt a lot from.

tahamalas
Автор

is this tutorial part of a series weather app?

greyabeing
Автор

The problem of using another pointer mapGetWeatherToState is you will not be able to use local variables directly, you need to pass them in attributes

peekpt
Автор

It's bird, it's a plane, no, it's super-enum :o

peekpt
Автор

I dont like code generation libraries but anyway great job resoC O D E R

Linxy
Автор

How would you deal with not wanting a specific property to be picked up by Equatable ? e.g.: I don't want a specific property from a state class to influence equality between two state objects. At first glance it seems you don't have a choice.

narcodico
Автор

Matt, you could look at Mobx, it's awesome!

peekpt
Автор

Nice tutorial but could you also show us how this can be tested?

TheFitnessGmer
Автор

Quite disappointed to see that @Reso code is uninformed as We have had Sealed Class equivalent for well over 2 years (started with Dart 1!)

and that there are other packages making use of them:

nodinosaur