apply TextSelectionMenuFix

Signed-off-by: dom <githubaccount56556@proton.me>
This commit is contained in:
dom
2026-07-18 13:55:51 +08:00
parent 3d4aa7d5a9
commit cf27cf8b5f
2 changed files with 25 additions and 3 deletions

View File

@@ -4301,7 +4301,7 @@ class EditableTextState extends State<EditableText>
return;
}
_showToolbarOnScreenScheduled = true;
SchedulerBinding.instance.addPostFrameCallback((Duration _) {
void scheduleToolbar(Duration _) {
_showToolbarOnScreenScheduled = false;
if (!mounted || _dataWhenToolbarShowScheduled == null) {
return;
@@ -4331,7 +4331,25 @@ class EditableTextState extends State<EditableText>
showToolbar();
_dataWhenToolbarShowScheduled = null;
}
}, debugLabel: 'EditableText.scheduleToolbar');
}
switch (SchedulerBinding.instance.schedulerPhase) {
case SchedulerPhase.idle:
case SchedulerPhase.postFrameCallbacks:
// During these scheduler phases we cannot guarantee
// there will be a frame after, so we use scheduleFrameCallback.
SchedulerBinding.instance.scheduleFrameCallback(scheduleToolbar);
case SchedulerPhase.transientCallbacks:
case SchedulerPhase.midFrameMicrotasks:
case SchedulerPhase.persistentCallbacks:
// During an active frame we can still schedule
// a post-frame callback to be run after the
// current frame.
SchedulerBinding.instance.addPostFrameCallback(
scheduleToolbar,
debugLabel: 'EditableText.scheduleToolbar',
);
}
}
}