setData method

  1. @protected
void setData(
  1. S data, {
  2. bool forced = false,
  3. bool notify = true,
})

Transitions the notifier to the data state with the given data.

data is the successful result of the async operation. forced (default: false): Forces the state update even if the value hasn't changed. notify (default: true): Controls whether listeners are notified and the UI is rebuilt.

Use this when an async operation completes successfully.

Example:

void onDataReceived(String data) {
  setData(data);
}

void updateSilently(String data) {
  setData(data, notify: false); // Update without notifying listeners
}

void forceUpdate(String data) {
  setData(data, forced: true); // Updates the state bypassing the equality check
}

Implementation

@protected
void setData(
  S data, {
  bool forced = false,
  bool notify = true,
}) {
  return setState(
    notify: notify,
    forced: forced,
    state.toData(data),
  );
}