Skip to content

RenderParagraph.getFullHeightForCaret and TextPainter.getFullHeightForCaret shouldn't be nullable #145507

Closed

Description

@angelosilvestre

The getFullHeightForCaret declared in RenderParagraph and TextPainter has a return type of double?, but looking at the implementation it seems it couldn't possibly return null:

/// {@macro flutter.painting.textPainter.getFullHeightForCaret}
///
/// Valid only after [layout].
double? getFullHeightForCaret(TextPosition position) {
assert(!debugNeedsLayout);
_layoutTextWithConstraints(constraints);
return _textPainter.getFullHeightForCaret(position, Rect.zero);
}

/// {@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) {
final TextBox textBox = _getOrCreateLayoutTemplate().getBoxesForRange(0, 1, boxHeightStyle: ui.BoxHeightStyle.strut).single;
return textBox.toRect().height;
}

If the return type must be nullable, then it should be documented why. Otherwise, the return type should be changed to double.

Activity

  1. added
    in triagePresently being triaged by the triage team
    frameworkflutter/packages/flutter repository. See also f: labels.
    d: api docsIssues with https://api.flutter.dev/
    a: typographyText rendering, possibly libtxt
    and removed
    in triagePresently being triaged by the triage team
    on Mar 21, 2024
  2. github-actions commented on Apr 5, 2024

    @github-actions

    This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of flutter doctor -v and a minimal reproduction of the issue.

  3. locked as resolved and limited conversation to collaborators on Apr 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    a: typographyText rendering, possibly libtxtd: api docsIssues with https://api.flutter.dev/frameworkflutter/packages/flutter repository. See also f: labels.team-frameworkOwned by Framework team

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions