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; return;
} }
_showToolbarOnScreenScheduled = true; _showToolbarOnScreenScheduled = true;
SchedulerBinding.instance.addPostFrameCallback((Duration _) { void scheduleToolbar(Duration _) {
_showToolbarOnScreenScheduled = false; _showToolbarOnScreenScheduled = false;
if (!mounted || _dataWhenToolbarShowScheduled == null) { if (!mounted || _dataWhenToolbarShowScheduled == null) {
return; return;
@@ -4331,7 +4331,25 @@ class EditableTextState extends State<EditableText>
showToolbar(); showToolbar();
_dataWhenToolbarShowScheduled = null; _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',
);
}
} }
} }

View File

@@ -12,6 +12,10 @@ $BottomSheetAndroidPatch = "lib/scripts/bottom_sheet_android.patch"
$BottomSheetIOSFlutterPatch = "lib/scripts/bottom_sheet_ios_flutter.patch" $BottomSheetIOSFlutterPatch = "lib/scripts/bottom_sheet_ios_flutter.patch"
$BottomSheetIOSPiliPlusPatch = "lib/scripts/bottom_sheet_ios_piliplus.patch" $BottomSheetIOSPiliPlusPatch = "lib/scripts/bottom_sheet_ios_piliplus.patch"
# TODO: remove
# https://github.com/flutter/flutter/issues/185052
$TextSelectionMenuFix = "beb2ad17004a1b118ff2bd09f55cee23198f6652";
# https://github.com/bggRGjQaUbCoE/PiliPlus/issues/1662 # https://github.com/bggRGjQaUbCoE/PiliPlus/issues/1662
$ScrollViewPatch = "lib/scripts/scroll_view.patch" $ScrollViewPatch = "lib/scripts/scroll_view.patch"
@@ -66,7 +70,7 @@ if ($platform.ToLower() -eq "ios") {
Set-Location $env:FLUTTER_ROOT Set-Location $env:FLUTTER_ROOT
$picks = @() $picks = @($TextSelectionMenuFix)
$reverts = @() $reverts = @()
$patches = @($ModalBarrierPatch, $TextSelectionPatch, $MouseCursorPatch, $patches = @($ModalBarrierPatch, $TextSelectionPatch, $MouseCursorPatch,
$ImageAnimPatch, $LayoutBuilderPatch, $NavigationDrawerPatch, $ImageAnimPatch, $LayoutBuilderPatch, $NavigationDrawerPatch,