From 0aa1a9cee03dd29a8529613a279c3b485e8bf03b Mon Sep 17 00:00:00 2001 From: Cheryl Zhang Date: Fri, 9 Jul 2021 23:26:15 -0700 Subject: [PATCH] Format code --- lib/src/widgets/editor.dart | 8 +++++--- lib/src/widgets/text_selection.dart | 10 +++++----- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/lib/src/widgets/editor.dart b/lib/src/widgets/editor.dart index f5ce06e1..59a031a0 100644 --- a/lib/src/widgets/editor.dart +++ b/lib/src/widgets/editor.dart @@ -903,19 +903,21 @@ class RenderEditor extends RenderEditableContainerBox double? getOffsetToRevealCursor( double viewportHeight, double scrollOffset, double offsetInViewport) { final endpoints = getEndpointsForSelection(selection); - + // when we drag the right handle, we should get the last point TextSelectionPoint endpoint; if (selection.isCollapsed) { endpoint = endpoints.first; } else { if (selection is DragTextSelection) { - endpoint = (selection as DragTextSelection).first ? endpoints.first : endpoints.last; + endpoint = (selection as DragTextSelection).first + ? endpoints.first + : endpoints.last; } else { endpoint = endpoints.first; } } - + final child = childAtPosition(selection.extent); const kMargin = 8.0; diff --git a/lib/src/widgets/text_selection.dart b/lib/src/widgets/text_selection.dart index 583f7794..f11a42c4 100644 --- a/lib/src/widgets/text_selection.dart +++ b/lib/src/widgets/text_selection.dart @@ -25,12 +25,10 @@ enum _TextSelectionHandlePosition { START, END } /// internal use, used to get drag direction information class DragTextSelection extends TextSelection { - final bool first; - const DragTextSelection({ + TextAffinity affinity = TextAffinity.downstream, int baseOffset = 0, int extentOffset = 0, - TextAffinity affinity = TextAffinity.downstream, bool isDirectional = false, this.first = true, }) : super( @@ -40,6 +38,8 @@ class DragTextSelection extends TextSelection { isDirectional: isDirectional, ); + final bool first; + @override DragTextSelection copyWith({ int? baseOffset, @@ -191,7 +191,7 @@ class EditorTextSelectionOverlay { default: throw 'Invalid position'; } - + final currSelection = newSelection != null ? DragTextSelection( baseOffset: newSelection.baseOffset, @@ -201,7 +201,7 @@ class EditorTextSelectionOverlay { first: position == _TextSelectionHandlePosition.START, ) : null; - + selectionDelegate ..userUpdateTextEditingValue( value.copyWith(selection: currSelection, composing: TextRange.empty),