setStateWithUpdater method
void
setStateWithUpdater(
- Component2 component,
- StateUpdaterCallback stateUpdater,
- SetStateCallback? callback
override
Implementation
@override
void setStateWithUpdater(Component2 component, StateUpdaterCallback stateUpdater, SetStateCallback? callback) {
final firstArg = allowInterop((JsMap jsPrevState, JsMap jsProps, [_]) {
final value = stateUpdater(
JsBackedMap.backedBy(jsPrevState),
JsBackedMap.backedBy(jsProps),
);
if (value == null) return null;
return jsBackingMapOrJsCopy(value);
});
if (callback == null) {
component.jsThis.setState(firstArg);
} else {
component.jsThis.setState(firstArg, allowInterop(([_]) {
callback();
}));
}
}