Widgets vs helper methods | Decoding Flutter

preview_player
Показать описание
Flutter developers are well-acquainted with widget build methods that grow, and grow… and grow. In this video, Craig Labenz compares two different ways to break up those unwieldy build methods; and how the best option may be different than what you originally suspected.

See the differences in action in these DartPads:


#DecodingFlutter #Flutter #Developer

product: Flutter - Development - User interface;
Рекомендации по теме
Комментарии
Автор

thanks, that was so important to me i used helper methods, but from now i will use classes

hawarhekmat
Автор

At least in VSC, the "refactor selected code to separate widget class" will notice variables defined out of scope, and automatically add them as parameters to the new class, providing the proper linkage at the original site. It stunned me the first time I tried that and it just worked. :)

RandalLSchwartz
Автор

Greeeat video, it helped me a lot!
As a novice in flutter I've started to use different classes for widgets right from the beginning as it felt logical for me. But watching more and more tutorials I've found out that people in them use helper method extensively and switched to that approach as it seemed easier to transfer data that way.
Now, this video put thing in correct perspective and explains why it's not the best way

OKOK-hmis
Автор

Key takeaway
1. Use classes instead of helper functions
2. Use const constructor wherever possible

anymore ?

brendanlovelife
Автор

I was editing the widgets today and I was confused about the difference and this video helped me, thanks!

myavuzokumus
Автор

Great Video! I have one minor addition. We can actually convert helper methods to generated widgets via functional_widget package.
This way we get rid of both new class boilerplate and side effects of helper methods.

AhmetZorer
Автор

I always used to use class constructors, because it makes code looks more readable and clearer for me. It's happy to hear that there are more valuable advantages too 😊.

lahirudx
Автор

Great video! I want to add that naming your helpers or classes well is very important!

Aspiiire
Автор

That was just soo helpful! As a new flutter developer, I just can't underestimate the value of such and advice!

danillubruk
Автор

Ah crap, I need to rewrite a few things. Thanks! Backlog item added

Vilmir
Автор

i like your explanation style and pace... slow and clear with simple examples, makes it really easy to absord

warperone
Автор

Thank you for yet another great video! I knew about it, but it's always good to refresh in memory.
The only thing I don't like is `const` keywords everywhere.
Okay, we don't have that annoying `new` keyword, but we have to print `const` again and again. Is it really that difficult to make the compiler smarter, so it would automatically add consts in front of widgets? If it already has a lint, suggesting const, why not to get rid of `const` in front of constructor and make a compiler to add it when app is building?

sergey_molchanovsky
Автор

I was using the the helper method approach... But from now, I will use another class to wrap my Child widget build methods....

Thanks for the insight... Much appreciated...

AnirbanChakraborty
Автор

So relieved I have had developed a habit of separating widgets

gameplaystrailers
Автор

Classes are always great since you can isolate them to a separate file. As your app grows bigger and complex, it becomes easier to fix bugs when things are isolated. The logic is also easier to follow when code is broken down instead of having over 2000 lines in a single file

thefamousdjx
Автор

I've been looking for this video for a while. Now I got it clear. Thanks👏

HAROLHIGUERA
Автор

I just start to do it recently and my app performance got much better 🙂

jchjkitv
Автор

This is a extrenely valuable information. Thanks

heshansandeepa
Автор

I also had thoughts about this topic. I started using separate classes for widgets but main problem I face with that is passing variables and callbacks are a bit challenging.

TheAbhidugar
Автор

Thanks! Although I knew it already I needed to hear it from the flutter team again 😅!

verry_codes
visit shbcf.ru