Unverified Commit bb59993a authored by Anatoly Pulyaevskiy's avatar Anatoly Pulyaevskiy Committed by GitHub

Expose 3 new methods with text metrics in RenderParagraph (#65150)

parent 0d8de393
......@@ -784,7 +784,9 @@ class TextPainter {
return _caretMetrics.offset;
}
/// Returns the tight bounded height of the glyph at the given [position].
/// {@template flutter.painting.textPainter.getFullHeightForCaret}
/// Returns the strut bounded height of the glyph at the given `position`.
/// {@endtemplate}
///
/// Valid only after [layout] has been called.
double? getFullHeightForCaret(TextPosition position, Rect caretPrototype) {
......
......@@ -744,6 +744,15 @@ class RenderParagraph extends RenderBox
return _textPainter.getOffsetForCaret(position, caretPrototype);
}
/// {@macro flutter.painting.textPainter.getFullHeightForCaret}
///
/// Valid only after [layout].
double? getFullHeightForCaret(TextPosition position) {
assert(!debugNeedsLayout);
_layoutTextWithConstraints(constraints);
return _textPainter.getFullHeightForCaret(position, Rect.zero);
}
/// Returns a list of rects that bound the given selection.
///
/// A given selection might have more than one rect if this text painter
......
......@@ -36,6 +36,17 @@ void main() {
expect(offset50.dy, greaterThan(offset5.dy));
});
test('getFullHeightForCaret control test', () {
final RenderParagraph paragraph = RenderParagraph(
const TextSpan(text: _kText,style: TextStyle(fontSize: 10.0)),
textDirection: TextDirection.ltr,
);
layout(paragraph);
final double height5 = paragraph.getFullHeightForCaret(const TextPosition(offset: 5));
expect(height5, equals(10.0));
});
test('getPositionForOffset control test', () {
final RenderParagraph paragraph = RenderParagraph(
const TextSpan(text: _kText),
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment