getFullHeightForCaret method
- TextPosition position,
- Rect caretPrototype
Returns the strut bounded height of the glyph at the given position.
Valid only after layout has been called.
Implementation
double getFullHeightForCaret(TextPosition position, Rect caretPrototype) {
if (_strutDisabled) {
final double? heightFromCaretMetrics = _computeCaretMetrics(position)?.height;
if (heightFromCaretMetrics != null) {
return heightFromCaretMetrics;
}
}
final List<TextBox> boxes = _getOrCreateLayoutTemplate().getBoxesForRange(
0,
1,
boxHeightStyle: .strut,
);
// The list may be empty under degenerate layout configurations (e.g., when
// the TextStyle.height is non-zero and TextStyle.fontSize or textScaler is
// 0.0). In such cases, we fall back to preferredLineHeight.
if (boxes.isEmpty) {
return preferredLineHeight;
}
return boxes.single.toRect().height;
}