setStateIfMounted method

void setStateIfMounted(
  1. VoidCallback fn
)

Calls setState if the widget is mounted.

fn is only called if the widget is mounted.

Implementation

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