safeSetState method

FutureOr<void> safeSetState(
  1. FutureOr fn()
)

安全刷新

Implementation

FutureOr<void> safeSetState(FutureOr<dynamic> Function() fn) async {
  if (mounted &&
      !context.debugDoingBuild &&
      context.owner?.debugBuilding == false) {
    await fn();
    setState(() {});
  }
}