setState function

void setState(
  1. bool mounted,
  2. void setState(
    1. dynamic ()
    ),
  3. void fn()
)

small function to always check if mounted before running setState()

Implementation

void setState(bool mounted, void Function(Function()) setState, void Function() fn) {
  if (mounted) {
    setState.call(fn);
  }
}