diff --git a/lib/src/widgets/proxy.dart b/lib/src/widgets/proxy.dart index a1cb8c6a..45a513b2 100644 --- a/lib/src/widgets/proxy.dart +++ b/lib/src/widgets/proxy.dart @@ -1,3 +1,5 @@ +import 'dart:ui'; + import 'package:flutter/rendering.dart'; import 'package:flutter/widgets.dart'; @@ -291,8 +293,8 @@ class RenderParagraphProxy extends RenderProxyBox child!.getWordBoundary(position); @override - List getBoxesForSelection(TextSelection selection) => - child!.getBoxesForSelection(selection); + List getBoxesForSelection(TextSelection selection) => child! + .getBoxesForSelection(selection, boxHeightStyle: BoxHeightStyle.strut); @override void performLayout() { diff --git a/lib/src/widgets/text_line.dart b/lib/src/widgets/text_line.dart index 5e365272..d2762f7c 100644 --- a/lib/src/widgets/text_line.dart +++ b/lib/src/widgets/text_line.dart @@ -441,9 +441,10 @@ class RenderEditableTextLine extends RenderEditableBox { } final containsSelection = containsTextSelection(); - if (attached && containsCursor()) { + if (_attachedToCursorController) { cursorCont.removeListener(markNeedsLayout); cursorCont.color.removeListener(safeMarkNeedsPaint); + _attachedToCursorController = false; } textSelection = t; @@ -452,6 +453,7 @@ class RenderEditableTextLine extends RenderEditableBox { if (attached && containsCursor()) { cursorCont.addListener(markNeedsLayout); cursorCont.color.addListener(safeMarkNeedsPaint); + _attachedToCursorController = true; } if (containsSelection || containsTextSelection()) { @@ -680,6 +682,8 @@ class RenderEditableTextLine extends RenderEditableBox { // Start render box overrides + bool _attachedToCursorController = false; + @override void attach(covariant PipelineOwner owner) { super.attach(owner); @@ -690,6 +694,7 @@ class RenderEditableTextLine extends RenderEditableBox { if (containsCursor()) { cursorCont.addListener(markNeedsLayout); cursorCont.color.addListener(safeMarkNeedsPaint); + _attachedToCursorController = true; } } @@ -701,9 +706,10 @@ class RenderEditableTextLine extends RenderEditableBox { } cursorCont.floatingCursorTextPosition .removeListener(_onFloatingCursorChange); - if (containsCursor()) { + if (_attachedToCursorController) { cursorCont.removeListener(markNeedsLayout); cursorCont.color.removeListener(safeMarkNeedsPaint); + _attachedToCursorController = false; } }