Skip to content

Let RenderEditable use LineMetrics instead of assuming every line has the same height #75572

Open

Description

@LongCatIsLooong

// The caret offset gives a location in the upper left hand corner of
// the caret so the middle of the line above is a half line above that
// point and the line below is 1.5 lines below that point.
final double preferredLineHeight = _textPainter.preferredLineHeight;
final double verticalOffset = upArrow ? -0.5 * preferredLineHeight : 1.5 * preferredLineHeight;
final Offset caretOffset = _textPainter.getOffsetForCaret(TextPosition(offset: newSelection.extentOffset), _caretPrototype);
final Offset caretOffsetTranslated = caretOffset.translate(0.0, verticalOffset);
final TextPosition position = _textPainter.getPositionForOffset(caretOffsetTranslated);

Vertical key movements may skip a line if that line is way shorter than its adjacent lines.

Activity

  1. added
    a: text inputEntering text in a text field or keyboard related problems
    frameworkflutter/packages/flutter repository. See also f: labels.
    on Feb 7, 2021
  2. LongCatIsLooong commented on Sep 20, 2021

    @LongCatIsLooong
    ContributorAuthor

    Additionally in a left-aligned text field:

    aaaaaaa|
    aaa
    aaaaaaaaaa
    

    pressing ↓ once should move the caret to the end of the second line:

    aaaaaaa
    aaa|
    aaaaaaaaaa
    

    press ↓ again should move the caret to the 3rd line, but further to the right:

    aaaaaaa
    aaa
    aaaaaaa|aaa
    
  3. added
    P1High-priority issues at the top of the work list
    on Sep 20, 2021
  4. added
    P2Important issues not at the top of the work list
    and removed
    P1High-priority issues at the top of the work list
    on Nov 5, 2025
  5. removed their assignment
    on Mar 5, 2026
  6. added
    packageflutter/packages repository. See also p: labels.
    and removed
    frameworkflutter/packages/flutter repository. See also f: labels.
    on Aug 17, 2026
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

    P2Important issues not at the top of the work lista: text inputEntering text in a text field or keyboard related problemsc: tech-debtTechnical debt, code quality, testing, etc.p: material_uimaterial_ui package in flutter/packagespackageflutter/packages repository. See also p: labels.team-designOwned by Design Languages teamtriaged-designTriaged by Design Languages team

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions