'Flutter web performance with getx
I'm using getx
state management for flutter. I read a few articles (blog.codemagic.io, itnext.io) that explain that we shouldn't use methods for widgets because you can save CPU cycles and use them with a const constructor to make rebuild when only needed and much more benefits.
My question is, Is it necessary to use classes instead of methods when I use getx
?
Solution 1:[1]
The best way to figure this out is to actually dive into the code of GetX itself.
If you look at the Obx
source code, you will see that Obx
itself is actually a widget (with a const
constructor, to boot). So, when you're typing Obx(...)
, you are not calling a helper method, but actually instantiating a widget class.
So, to answer your last question: no, to use GetX you don't need to do any extra class
wrapping. Obx
itself is already a Widget class with a const
constructor.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | b0nyb0y |