safeSetState method

void safeSetState(
  1. VoidCallback fn
)

Check if the widget exist before safely setting state.

Implementation

void safeSetState(VoidCallback fn) {
  if (mounted) {
    // ignore: invalid_use_of_protected_member
    setState(fn);
  }
}