safeSetState method

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

安全刷新

Implementation

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