As the title reads, there are a couple of ways to update state. When should I choose one over another?
Asked
Active
Viewed 1.1k times
13
-
https://stackoverflow.com/questions/65405741/how-to-flutter-getx-binds-obs-to-widget This link has answer of your question – Hassan Apr 16 '21 at 09:02
1 Answers
40
There's no hard rules about this, but here's how I try to decide:
Obx
- when my controller is already registered elsewhere and I want
- minimal code/noise
- a reactive widget
GetX
- when my controller isn't yet registered or
- I want to be very explicit/obvious which controller is being used or
- I need to run some
initState
calls during creation and I want - a reactive widget
GetBuilder
- I want to manually decide when a widget rebuilds
- I have several state variables that make sense to refresh together as a group
Notes
Under the hood, both Obx and GetX use streams, subscribing to controller observable variables change streams to know when to reactively rebuild.
GetBuilder does not.
GetX and GetBuilder both extend StatefulWidget

Baker
- 24,730
- 11
- 100
- 106