update method
- TextEditingValue newValue
Updates the overlay after the selection has changed.
If this method is called while the SchedulerBinding.schedulerPhase is SchedulerPhase.persistentCallbacks, i.e. during the build, layout, or paint phases (see WidgetsBinding.drawFrame), then the update is delayed until the post-frame callbacks phase. Otherwise the update is done synchronously. This means that it is safe to call during builds, but also that if you do call this during a build, the UI will not update until the next frame (i.e. many milliseconds later).
Implementation
void update(TextEditingValue newValue) {
if (_value == newValue) {
return;
}
_value = newValue;
_updateSelectionOverlay();
// _updateSelectionOverlay may not rebuild the selection overlay if the
// text metrics and selection doesn't change even if the text has changed.
// This rebuild is needed for the toolbar to update based on the latest text
// value.
_selectionOverlay.markNeedsBuild();
}