From 6b9795ad005502fa99bbd79d5032df74dec5d3c6 Mon Sep 17 00:00:00 2001 From: gtyhn <122523252@qq.com> Date: Sat, 10 Jul 2021 01:23:16 +0800 Subject: [PATCH] Fixed the position of the selection status drag handle (#288) * fix the OnImagePickCallback return value * solve placeholder issue, removing must focus * Fixed the position of the selection status drag handle --- lib/src/widgets/text_selection.dart | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/lib/src/widgets/text_selection.dart b/lib/src/widgets/text_selection.dart index 85362c7a..96e5310f 100644 --- a/lib/src/widgets/text_selection.dart +++ b/lib/src/widgets/text_selection.dart @@ -287,6 +287,9 @@ class _TextSelectionHandleOverlay extends StatefulWidget { class _TextSelectionHandleOverlayState extends State<_TextSelectionHandleOverlay> with SingleTickerProviderStateMixin { + + late Offset _dragPosition; + late Size _handleSize; late AnimationController _controller; Animation get _opacity => _controller.view; @@ -325,11 +328,14 @@ class _TextSelectionHandleOverlayState super.dispose(); } - void _handleDragStart(DragStartDetails details) {} + void _handleDragStart(DragStartDetails details) { + _dragPosition = details.globalPosition + Offset(0.0, -_handleSize.height); + } void _handleDragUpdate(DragUpdateDetails details) { + _dragPosition += details.delta; final position = - widget.renderObject!.getPositionForOffset(details.globalPosition); + widget.renderObject!.getPositionForOffset(_dragPosition); if (widget.selection.isCollapsed) { widget.onSelectionHandleChanged(TextSelection.fromPosition(position)); return; @@ -398,6 +404,7 @@ class _TextSelectionHandleOverlayState final handleAnchor = widget.selectionControls.getHandleAnchor(type!, lineHeight); final handleSize = widget.selectionControls.getHandleSize(lineHeight); + _handleSize = handleSize; final handleRect = Rect.fromLTWH( -handleAnchor.dx,