From 778657809e69eb3f77ce54108e5e08a0318afae4 Mon Sep 17 00:00:00 2001 From: zmtzawqlp Date: Mon, 1 Jun 2020 09:58:08 +0800 Subject: [PATCH] ## [1.0.1] * Fix wrong calculation about selection handles. --- CHANGELOG.md | 4 +++ lib/src/extended_render_editable.dart | 36 ++++++++++++++------------- pubspec.yaml | 2 +- 3 files changed, 24 insertions(+), 18 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2f4fd0b..fd10a7a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +## [1.0.1] + +* Fix wrong calculation about selection handles. + ## [1.0.0] * Merge code from 1.17.0 diff --git a/lib/src/extended_render_editable.dart b/lib/src/extended_render_editable.dart index 4622c92..e0d2328 100644 --- a/lib/src/extended_render_editable.dart +++ b/lib/src/extended_render_editable.dart @@ -330,16 +330,17 @@ class ExtendedRenderEditable extends ExtendedTextSelectionRenderObject { /// final Rect visibleRegion = Offset(0.0, _visibleRegionMinY) & size; - + + //getCaretOffset ready has effectiveOffset final Offset startOffset = getCaretOffset( - TextPosition( - offset: selection.start, - affinity: selection.affinity, - ), - effectiveOffset: effectiveOffset, - caretPrototype: _caretPrototype, - handleSpecialText: handleSpecialText, - ); + TextPosition( + offset: selection.start, + affinity: selection.affinity, + ), + effectiveOffset: effectiveOffset, + caretPrototype: _caretPrototype, + handleSpecialText: handleSpecialText, + ); // (justinmc): https://github.com/flutter/flutter/issues/31495 // Check if the selection is visible with an approximation because a @@ -351,18 +352,19 @@ class ExtendedRenderEditable extends ExtendedTextSelectionRenderObject { const double visibleRegionSlop = 0.5; _selectionStartInViewport.value = visibleRegion .inflate(visibleRegionSlop) - .contains(startOffset + effectiveOffset); - + .contains(startOffset); + + //getCaretOffset ready has effectiveOffset final Offset endOffset = getCaretOffset( - TextPosition(offset: selection.end, affinity: selection.affinity), - effectiveOffset: effectiveOffset, - caretPrototype: _caretPrototype, - handleSpecialText: handleSpecialText, - ); + TextPosition(offset: selection.end, affinity: selection.affinity), + effectiveOffset: effectiveOffset, + caretPrototype: _caretPrototype, + handleSpecialText: handleSpecialText, + ); _selectionEndInViewport.value = visibleRegion .inflate(visibleRegionSlop) - .contains(endOffset + effectiveOffset); + .contains(endOffset); } ///some times _visibleRegionMinY will lower than 0.0; diff --git a/pubspec.yaml b/pubspec.yaml index ee7dbdf..cbea9ed 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,6 +1,6 @@ name: extended_text_field description: Extended official text field to build special text like inline image, @somebody, custom background etc quickly.It also support to build custom seleciton toolbar and handles. -version: 1.0.0 +version: 1.0.1 author: zmtzawqlp homepage: https://github.com/fluttercandies/extended_text_field