systemFontsDidChange method Null safety
override
A callback that is called when system fonts have changed.
By default, markNeedsLayout is called on the RenderObject implementing this mixin.
Subclass should override this method to clear any extra cache that depend on font-related metrics.
Implementation
@override
void systemFontsDidChange() {
final SchedulerPhase phase = SchedulerBinding.instance.schedulerPhase;
switch (phase) {
case SchedulerPhase.idle:
case SchedulerPhase.postFrameCallbacks:
if (_systemFontsChangeScheduled) {
return;
}
_systemFontsChangeScheduled = true;
SchedulerBinding.instance.scheduleFrameCallback((Duration timeStamp) {
assert(_systemFontsChangeScheduled);
_systemFontsChangeScheduled = false;
assert(
attached || (debugDisposed ?? true),
'$this is detached during $phase but not disposed.',
);
if (attached) {
super.systemFontsDidChange();
_textPainter.markNeedsLayout();
}
});
break;
case SchedulerPhase.transientCallbacks:
case SchedulerPhase.midFrameMicrotasks:
case SchedulerPhase.persistentCallbacks:
super.systemFontsDidChange();
_textPainter.markNeedsLayout();
break;
}
}