From a97323810000682b6a2483474024ba4012050d7e Mon Sep 17 00:00:00 2001 From: X Code Date: Sun, 30 Jan 2022 01:36:02 -0800 Subject: [PATCH] Update selectionCtrls.buildToolbar --- lib/src/widgets/text_selection.dart | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/src/widgets/text_selection.dart b/lib/src/widgets/text_selection.dart index 92f029a3..137979a0 100644 --- a/lib/src/widgets/text_selection.dart +++ b/lib/src/widgets/text_selection.dart @@ -322,12 +322,16 @@ class EditorTextSelectionOverlay { final isMultiline = endpoints.last.point.dy - endpoints.first.point.dy > smallestLineHeight / 2; + // If the selected text spans more than 1 line, + // horizontally center the toolbar. + // Derived from both iOS and Android. final midX = isMultiline ? editingRegion.width / 2 : (endpoints.first.point.dx + endpoints.last.point.dx) / 2; final midpoint = Offset( midX, + // The y-coordinate won't be made use of most likely. endpoints[0].point.dy - baseLineHeight, ); @@ -345,7 +349,7 @@ class EditorTextSelectionOverlay { endpoints, selectionDelegate, clipboardStatus, - const Offset(0, 0)), + null), ), ); }