enableSemantics method

void enableSemantics(
  1. bool on
)

Turns the semantics tree on or off.

Idempotent both ways. Turning on schedules a frame, because the tree is built by a frame and an idle guest would otherwise never produce one — the read polls until it appears.

Implementation

void enableSemantics(bool on) {
  if (on) {
    if (_semantics != null) return;
    _semantics = SemanticsBinding.instance.ensureSemantics();
    SchedulerBinding.instance.ensureVisualUpdate();
  } else {
    _semantics?.dispose();
    _semantics = null;
  }
}