From 97851f69a5e6a438ec5300ebef366feddfe180f4 Mon Sep 17 00:00:00 2001 From: FERAS ABDALRAHMAN Date: Wed, 17 May 2023 20:59:47 +0300 Subject: [PATCH] Fix Rtl leading alignment problem --- lib/src/widgets/raw_editor.dart | 2 +- lib/src/widgets/text_line.dart | 13 ++++++++++--- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/lib/src/widgets/raw_editor.dart b/lib/src/widgets/raw_editor.dart index b80aa1b2..444c49dd 100644 --- a/lib/src/widgets/raw_editor.dart +++ b/lib/src/widgets/raw_editor.dart @@ -891,7 +891,7 @@ class RawEditorState extends EditorState final editableTextBlock = EditableTextBlock( block: node, controller: controller, - textDirection: _textDirection, + textDirection: getDirectionOfNode(node), scrollBottomInset: widget.scrollBottomInset, verticalSpacing: _getVerticalSpacingForBlock(node, _styles), textSelection: controller.selection, diff --git a/lib/src/widgets/text_line.dart b/lib/src/widgets/text_line.dart index f38cbebf..467fddb2 100644 --- a/lib/src/widgets/text_line.dart +++ b/lib/src/widgets/text_line.dart @@ -1082,9 +1082,16 @@ class RenderEditableTextLine extends RenderEditableBox { @override void paint(PaintingContext context, Offset offset) { if (_leading != null) { - final parentData = _leading!.parentData as BoxParentData; - final effectiveOffset = offset + parentData.offset; - context.paintChild(_leading!, effectiveOffset); + if (textDirection == TextDirection.ltr) { + final parentData = _leading!.parentData as BoxParentData; + final effectiveOffset = offset + parentData.offset; + context.paintChild(_leading!, effectiveOffset); + } else { + final parentData = _leading!.parentData as BoxParentData; + final effectiveOffset = offset + parentData.offset; + context.paintChild(_leading!, + Offset(size.width - _leading!.size.width, effectiveOffset.dy)); + } } if (_body != null) {