Skip to content

TextWidthBasis.longestLine prevents text from unwrapping when width constraints increase #133687

@hobgoblina

Description

@hobgoblina

Is there an existing issue for this?

Use case

Providing textWidthBasis: TextWidthBasis.longestLine to a Text widget ensures that the widget's width will fit the width of its text when the text is wrapped, rather than filling leftover width in the parent. However, if the inherited width constraint increases (eg, if its parent's width increases), TextWidthBasis.longestLine prevents the text from unwrapping even though the text no longer exceeds its width constraint.

This can be especially noticeable for mobile device when switching the device orientation from portrait to landscape. Text that needed to wrap in portrait mode remains wrapped in landscape even with significantly more available width and significantly less available height.

Proposal

If this is an unintended consequence of TextWidthBasis.longestLine, then maybe it requires a bugfix. Otherwise, it would be great if we had a third option - something like TextWidthBasis.expandingLongestLine - that constraints the width of the Text widget to the longest line but still determines line wrapping from the width constraint inherited by the parent.

Metadata

Metadata

Assignees

No one assigned

    Labels

    in triagePresently being triaged by the triage teamwaiting for customer responseThe Flutter team cannot make further progress on this issue until the original reporter responds

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions