in flutter: extracting a widget
"A reference to an enclosing class method can't be extracted," ERROR
this happens when the widget we are trying to extract uses setState
(which is specific to statefull widgets)
and it means = NO ACCESS TO setState method
HOW TO FIX THIS?
b-1: Extract with a callBack: The widget is stateful, but it communicates state changes to its parent via the callback,this maintains a single source of truth for the state.
b-2: Extract without a callBack in this case every instance will have its own internal state(isolation). which leads to a difficulty for parent widget to control or access the state.
Mostly we either extract as a function, as a stateless widget, or as a statefull widget with a callback.
when to extract as a statefull widget without a callBack?