setStateOf static method

bool setStateOf(
  1. StatefulWidget? widget,
  2. VoidCallback? fn
)

Calls the setState() of the State objet from the specified StatefulWidget passing the specified function. Return true if successful. Usually called in the StatefulWidget passing 'this' as a parameter.

Implementation

static bool setStateOf(StatefulWidget? widget, VoidCallback? fn) {
  bool set;

  final state = stateIn(widget);

  set = state != null;

  if (set) {
    set = state.mounted;
  }

  if (set) {
    set = fn != null;
  }

  if (set) {
    state!.setState(fn!);
  }
  return set;
}