Skip to content

Commit 88f7571

Browse files
authored
Remove irrelevant comment in TextPainter (flutter#144308)
This PR removes an irrelevant comment in `TextPainter` for `_computePaintOffsetFraction`. Also some typos are corrected and missing spaces/newlines added. test-exempt: no functional change
1 parent d00bfe8 commit 88f7571

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

packages/flutter/lib/src/painting/text_painter.dart

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -331,10 +331,10 @@ class _TextLayout {
331331
/// (text.length, downstream), unless maxLines is set to a non-null value, in
332332
/// which case the caret is placed at the visual end of the last visible line.
333333
///
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
335335
/// relies on line metrics.
336336
///
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
338338
/// levels have opposite parities (which implies opposite writing directions),
339339
/// this makes sure the caret is placed at the same "end" of the line as if the
340340
/// line ended with a line feed.
@@ -1045,6 +1045,7 @@ class TextPainter {
10451045
}
10461046

10471047
ui.Paragraph _getOrCreateLayoutTemplate() => _layoutTemplate ??= _createLayoutTemplate();
1048+
10481049
/// The height of a space in [text] in logical pixels.
10491050
///
10501051
/// Not every line of text in [text] will have this height, but this height
@@ -1305,8 +1306,6 @@ class TextPainter {
13051306
return isLowSurrogate(prevCodeUnit) ? offset - 2 : offset - 1;
13061307
}
13071308

1308-
// Get the caret metrics (in logical pixels) based off the trailing edge of the
1309-
// character upstream from the given string offset.
13101309
static double _computePaintOffsetFraction(TextAlign textAlign, TextDirection textDirection) {
13111310
return switch ((textAlign, textDirection)) {
13121311
(TextAlign.left, _) => 0.0,
@@ -1327,7 +1326,7 @@ class TextPainter {
13271326
final _LineCaretMetrics? caretMetrics = _computeCaretMetrics(position);
13281327

13291328
if (caretMetrics == null) {
1330-
final double paintOffsetAlignment = _computePaintOffsetFraction(textAlign, textDirection!);
1329+
final double paintOffsetAlignment = _computePaintOffsetFraction(textAlign, textDirection!);
13311330
// The full width is not (width - caretPrototype.width), because
13321331
// RenderEditable reserves cursor width on the right. Ideally this
13331332
// should be handled by RenderEditable instead.
@@ -1357,8 +1356,10 @@ class TextPainter {
13571356
final TextBox textBox = _getOrCreateLayoutTemplate().getBoxesForRange(0, 1, boxHeightStyle: ui.BoxHeightStyle.strut).single;
13581357
return textBox.toRect().height;
13591358
}
1359+
13601360
bool _isNewlineAtOffset(int offset) => 0 <= offset && offset < plainText.length
13611361
&& WordBoundary._isNewline(plainText.codeUnitAt(offset));
1362+
13621363
// Cached caret metrics. This allows multiple invokes of [getOffsetForCaret] and
13631364
// [getFullHeightForCaret] in a row without performing redundant and expensive
13641365
// get rect calls to the paragraph.
@@ -1464,7 +1465,7 @@ class TextPainter {
14641465
.getBoxesForRange(graphemeRange.start, graphemeRange.end, boxHeightStyle: ui.BoxHeightStyle.strut);
14651466
if (boxes.isNotEmpty) {
14661467
final TextBox box = boxes.single;
1467-
metrics =_LineCaretMetrics(
1468+
metrics = _LineCaretMetrics(
14681469
offset: Offset(anchorToLeadingEdge ? box.start : box.end, box.top),
14691470
writingDirection: box.direction,
14701471
);

0 commit comments

Comments
 (0)