safeSetState method

void safeSetState(
  1. VoidCallback? closure
)

Implementation

void safeSetState(VoidCallback? closure) {
  try {
    if (mounted) {
      setState(() {
        closure?.call();
      });
    }
  } catch (e) {
    setStateAfterFrame(closure);
  }
}