atDrawFrame top-level property

bool get atDrawFrame

当框架正在处理下一帧持久回调时(build/layout/paint),它将返回 true,当你在此阶段调用 setState 时, Flutter 框架将会抛出异常:setState() or markNeedsBuild() called during build.

Implementation

bool get atDrawFrame =>
    SchedulerBinding.instance.schedulerPhase ==
    SchedulerPhase.persistentCallbacks;