@@ -331,10 +331,10 @@ class _TextLayout {
331
331
/// (text.length, downstream), unless maxLines is set to a non-null value, in
332
332
/// which case the caret is placed at the visual end of the last visible line.
333
333
///
334
- /// This should not be called when the paragraph is emtpy as the implementation
334
+ /// This should not be called when the paragraph is empty as the implementation
335
335
/// relies on line metrics.
336
336
///
337
- /// When the last bidi level run in the paragraph and the parargraph 's bidi
337
+ /// When the last bidi level run in the paragraph and the paragraph 's bidi
338
338
/// levels have opposite parities (which implies opposite writing directions),
339
339
/// this makes sure the caret is placed at the same "end" of the line as if the
340
340
/// line ended with a line feed.
@@ -1045,6 +1045,7 @@ class TextPainter {
1045
1045
}
1046
1046
1047
1047
ui.Paragraph _getOrCreateLayoutTemplate () => _layoutTemplate ?? = _createLayoutTemplate ();
1048
+
1048
1049
/// The height of a space in [text] in logical pixels.
1049
1050
///
1050
1051
/// Not every line of text in [text] will have this height, but this height
@@ -1305,8 +1306,6 @@ class TextPainter {
1305
1306
return isLowSurrogate (prevCodeUnit) ? offset - 2 : offset - 1 ;
1306
1307
}
1307
1308
1308
- // Get the caret metrics (in logical pixels) based off the trailing edge of the
1309
- // character upstream from the given string offset.
1310
1309
static double _computePaintOffsetFraction (TextAlign textAlign, TextDirection textDirection) {
1311
1310
return switch ((textAlign, textDirection)) {
1312
1311
(TextAlign .left, _) => 0.0 ,
@@ -1327,7 +1326,7 @@ class TextPainter {
1327
1326
final _LineCaretMetrics ? caretMetrics = _computeCaretMetrics (position);
1328
1327
1329
1328
if (caretMetrics == null ) {
1330
- final double paintOffsetAlignment = _computePaintOffsetFraction (textAlign, textDirection! );
1329
+ final double paintOffsetAlignment = _computePaintOffsetFraction (textAlign, textDirection! );
1331
1330
// The full width is not (width - caretPrototype.width), because
1332
1331
// RenderEditable reserves cursor width on the right. Ideally this
1333
1332
// should be handled by RenderEditable instead.
@@ -1357,8 +1356,10 @@ class TextPainter {
1357
1356
final TextBox textBox = _getOrCreateLayoutTemplate ().getBoxesForRange (0 , 1 , boxHeightStyle: ui.BoxHeightStyle .strut).single;
1358
1357
return textBox.toRect ().height;
1359
1358
}
1359
+
1360
1360
bool _isNewlineAtOffset (int offset) => 0 <= offset && offset < plainText.length
1361
1361
&& WordBoundary ._isNewline (plainText.codeUnitAt (offset));
1362
+
1362
1363
// Cached caret metrics. This allows multiple invokes of [getOffsetForCaret] and
1363
1364
// [getFullHeightForCaret] in a row without performing redundant and expensive
1364
1365
// get rect calls to the paragraph.
@@ -1464,7 +1465,7 @@ class TextPainter {
1464
1465
.getBoxesForRange (graphemeRange.start, graphemeRange.end, boxHeightStyle: ui.BoxHeightStyle .strut);
1465
1466
if (boxes.isNotEmpty) {
1466
1467
final TextBox box = boxes.single;
1467
- metrics = _LineCaretMetrics (
1468
+ metrics = _LineCaretMetrics (
1468
1469
offset: Offset (anchorToLeadingEdge ? box.start : box.end, box.top),
1469
1470
writingDirection: box.direction,
1470
1471
);
0 commit comments