From ce01abfbc5ed79fc4d04f0507e6c28fd6311677c Mon Sep 17 00:00:00 2001 From: X Code Date: Thu, 6 Jan 2022 09:35:23 -0800 Subject: [PATCH] Update class RenderContentProxyBox --- lib/src/widgets/box.dart | 9 ++++++++- lib/src/widgets/proxy.dart | 10 ++++------ 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/lib/src/widgets/box.dart b/lib/src/widgets/box.dart index ad188c90..f26da691 100644 --- a/lib/src/widgets/box.dart +++ b/lib/src/widgets/box.dart @@ -13,7 +13,7 @@ import '../models/documents/nodes/container.dart'; abstract class RenderContentProxyBox implements RenderBox { double get preferredLineHeight; - Offset getOffsetForCaret(TextPosition position, Rect? caretPrototype); + Offset getOffsetForCaret(TextPosition position, Rect caretPrototype); TextPosition getPositionForOffset(Offset offset); @@ -21,6 +21,13 @@ abstract class RenderContentProxyBox implements RenderBox { TextRange getWordBoundary(TextPosition position); + /// Returns a list of rects that bound the given selection. + /// + /// A given selection might have more than one rect if this text painter + /// contains bidirectional text because logically contiguous text might not be + /// visually contiguous. + /// + /// Valid only after [layout] List getBoxesForSelection(TextSelection textSelection); } diff --git a/lib/src/widgets/proxy.dart b/lib/src/widgets/proxy.dart index 0e05fb2e..8f4d231f 100644 --- a/lib/src/widgets/proxy.dart +++ b/lib/src/widgets/proxy.dart @@ -104,14 +104,12 @@ class RenderEmbedProxy extends RenderProxyBox implements RenderContentProxyBox { double getFullHeightForCaret(TextPosition position) => size.height; @override - Offset getOffsetForCaret(TextPosition position, Rect? caretPrototype) { + Offset getOffsetForCaret(TextPosition position, Rect caretPrototype) { assert( position.offset == 1 || position.offset == 0 || position.offset == -1); return position.offset <= 0 ? Offset.zero - : Offset( - size.width - (caretPrototype == null ? 0 : caretPrototype.width), - 0); + : Offset(size.width - caretPrototype.width, 0); } @override @@ -275,8 +273,8 @@ class RenderParagraphProxy extends RenderProxyBox double get preferredLineHeight => _prototypePainter.preferredLineHeight; @override - Offset getOffsetForCaret(TextPosition position, Rect? caretPrototype) => - child!.getOffsetForCaret(position, caretPrototype!); + Offset getOffsetForCaret(TextPosition position, Rect caretPrototype) => + child!.getOffsetForCaret(position, caretPrototype); @override TextPosition getPositionForOffset(Offset offset) =>