Skip to content

Misleading error message in positionInlineChildren assert #182090

Closed

Description

@BrainLUX

When incorrectly implementing a custom InlineSpan, I encountered an assert inside the positionInlineChildren function with the following message:

The length of boxes (5) should be greater than childCount (1)

Looking only at this message, I would think my implementation is correct (5 is indeed greater than 1). However, the logic in the positionInlineChildren function expects the opposite: the number of boxes must NOT exceed the number of children (childCount).

  @protected
  void positionInlineChildren(List<ui.TextBox> boxes) {
    RenderBox? child = firstChild;
    for (final box in boxes) {
      if (child == null) {
        assert(
          false,
          'The length of boxes (${boxes.length}) should be greater than childCount ($childCount)',
        );
        return;
      }
      final textParentData = child.parentData! as TextParentData;
      textParentData._offset = Offset(box.left, box.top);
      child = childAfter(child);
    }
    while (child != null) {
      final textParentData = child.parentData! as TextParentData;
      textParentData._offset = null;
      child = childAfter(child);
    }
  }

The current message is logically incorrect and misleading for debugging.

Activity

  1. saurabh-mirajkar commented on Feb 10, 2026

    @saurabh-mirajkar
    Contributor

    @BrainLUX Thank you for pointing this out.
    Could you please provide the exact assertion message you are currently seeing and what you believe would be more helpful? This helps us ensure the new message covers the specific edge case you hit.

  2. added
    waiting for responseThe Flutter team cannot make further progress on this issue until the original reporter responds
    in triagePresently being triaged by the triage team
    on Feb 10, 2026
  3. BrainLUX commented on Feb 10, 2026

    @BrainLUX
    ContributorAuthor

    @BrainLUX Thank you for pointing this out. Could you please provide the exact assertion message you are currently seeing and what you believe would be more helpful? This helps us ensure the new message covers the specific edge case you hit.

    With pleasure.
    I'm seeing exact message:

    'The length of boxes (${boxes.length}) should be greater than childCount ($childCount)'

    And I want to change it to

    'The length of boxes (${boxes.length}) must not be greater than childCount ($childCount)'

    to make it more clearer.

    As I mentioned in #182093

  4. removed
    waiting for responseThe Flutter team cannot make further progress on this issue until the original reporter responds
    on Feb 10, 2026
  5. saurabh-mirajkar commented on Feb 11, 2026

    @saurabh-mirajkar
    Contributor

    @BrainLUX Thanks for the requested details.

  6. added
    frameworkflutter/packages/flutter repository. See also f: labels.
    c: renderingUI glitches reported at the engine/skia or impeller rendering level
    on Feb 11, 2026
  7. added
    P2Important issues not at the top of the work list
    on Feb 17, 2026
  8. github-actions commented on Mar 11, 2026

    @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.

  9. locked as resolved and limited conversation to collaborators on Mar 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

P2Important issues not at the top of the work listc: renderingUI glitches reported at the engine/skia or impeller rendering levelframeworkflutter/packages/flutter repository. See also f: labels.team-frameworkOwned by Framework teamtriaged-frameworkTriaged by Framework team

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions