diff --git a/bin/internal/goldens.version b/bin/internal/goldens.version index a4aae1372fa..2b9b50ea49b 100644 --- a/bin/internal/goldens.version +++ b/bin/internal/goldens.version @@ -1 +1 @@ -afef1dc571f94a41751917d3946defba782335f7 +055a75c5a63bf2b2c5142b38b88829593908fd10 diff --git a/packages/flutter/lib/src/painting/text_painter.dart b/packages/flutter/lib/src/painting/text_painter.dart index b0a36c5abff..56d66070a34 100644 --- a/packages/flutter/lib/src/painting/text_painter.dart +++ b/packages/flutter/lib/src/painting/text_painter.dart @@ -421,7 +421,7 @@ class TextPainter { return null; final TextBox box = boxes[0]; final double caretEnd = box.end; - final double dx = box.direction == TextDirection.rtl ? caretEnd : caretEnd - caretPrototype.width; + final double dx = box.direction == TextDirection.rtl ? caretEnd - caretPrototype.width : caretEnd; return Offset(dx, box.top); } diff --git a/packages/flutter/test/material/text_field_test.dart b/packages/flutter/test/material/text_field_test.dart index 5439ab00a79..a73ea0caea3 100644 --- a/packages/flutter/test/material/text_field_test.dart +++ b/packages/flutter/test/material/text_field_test.dart @@ -741,6 +741,11 @@ void main() { final Offset firstPos = textOffsetToPosition(tester, testValue.indexOf('First')); final Offset secondPos = textOffsetToPosition(tester, testValue.indexOf('Second')); final Offset thirdPos = textOffsetToPosition(tester, testValue.indexOf('Third')); + final Offset middleStringPos = textOffsetToPosition(tester, testValue.indexOf('irst')); + expect(firstPos.dx, 0); + expect(secondPos.dx, 0); + expect(thirdPos.dx, 0); + expect(middleStringPos.dx, 34); expect(firstPos.dx, secondPos.dx); expect(firstPos.dx, thirdPos.dx); expect(firstPos.dy, lessThan(secondPos.dy)); @@ -823,6 +828,8 @@ void main() { // Check that the last line of text is not displayed. final Offset firstPos = textOffsetToPosition(tester, kMoreThanFourLines.indexOf('First')); final Offset fourthPos = textOffsetToPosition(tester, kMoreThanFourLines.indexOf('Fourth')); + expect(firstPos.dx, 0); + expect(fourthPos.dx, 0); expect(firstPos.dx, fourthPos.dx); expect(firstPos.dy, lessThan(fourthPos.dy)); expect(inputBox.hitTest(HitTestResult(), position: inputBox.globalToLocal(firstPos)), isTrue);