Unverified Commit 11c034f0 authored by Michael Goderbauer's avatar Michael Goderbauer Committed by GitHub

Fix nullability of getFullHeightForCaret (#145554)

Fixes https://github.com/flutter/flutter/issues/145507.

Looks like this was accidentally migrated to nullable all the way back when we switched to NNBD.
parent 3b390c52
......@@ -1352,7 +1352,7 @@ class TextPainter {
/// {@endtemplate}
///
/// Valid only after [layout] has been called.
double? getFullHeightForCaret(TextPosition position, Rect caretPrototype) {
double getFullHeightForCaret(TextPosition position, Rect caretPrototype) {
final TextBox textBox = _getOrCreateLayoutTemplate().getBoxesForRange(0, 1, boxHeightStyle: ui.BoxHeightStyle.strut).single;
return textBox.toRect().height;
}
......
......@@ -1798,7 +1798,7 @@ class RenderEditable extends RenderBox with RelayoutWhenSystemFontsChangeMixin,
switch (defaultTargetPlatform) {
case TargetPlatform.iOS:
case TargetPlatform.macOS:
final double fullHeight = _textPainter.getFullHeightForCaret(caretPosition, caretPrototype) ?? _textPainter.preferredLineHeight;
final double fullHeight = _textPainter.getFullHeightForCaret(caretPosition, caretPrototype);
final double heightDiff = fullHeight - caretRect.height;
// Center the caret vertically along the text.
caretRect = Rect.fromLTWH(
......
......@@ -649,7 +649,7 @@ class RenderParagraph extends RenderBox with ContainerRenderObjectMixin<RenderBo
}
Offset _getOffsetForPosition(TextPosition position) {
return getOffsetForCaret(position, Rect.zero) + Offset(0, getFullHeightForCaret(position) ?? 0.0);
return getOffsetForCaret(position, Rect.zero) + Offset(0, getFullHeightForCaret(position));
}
@override
......@@ -952,7 +952,7 @@ class RenderParagraph extends RenderBox with ContainerRenderObjectMixin<RenderBo
/// {@macro flutter.painting.textPainter.getFullHeightForCaret}
///
/// Valid only after [layout].
double? getFullHeightForCaret(TextPosition position) {
double getFullHeightForCaret(TextPosition position) {
assert(!debugNeedsLayout);
_layoutTextWithConstraints(constraints);
return _textPainter.getFullHeightForCaret(position, Rect.zero);
......
......@@ -380,7 +380,7 @@ void main() {
final double caretHeight = painter.getFullHeightForCaret(
const ui.TextPosition(offset: 0),
ui.Rect.zero,
)!;
);
expect(caretHeight, 50.0);
painter.dispose();
}, skip: isBrowser && !isCanvasKit); // https://github.com/flutter/flutter/issues/56308
......
......@@ -121,7 +121,7 @@ void main() {
);
layout(paragraph);
final double height5 = paragraph.getFullHeightForCaret(const TextPosition(offset: 5))!;
final double height5 = paragraph.getFullHeightForCaret(const TextPosition(offset: 5));
expect(height5, equals(10.0));
});
......
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