Skip to content

[proposal] provide layout widget that enforces minimum height #46803

@feinstein

Description

@feinstein

I see many widgets meant to make its child as big as it wants, like Expanded, Flexible, BoxConstraints.expand(), SizedBox.expand, but many times I want to set a widget to be as small as possible, analog to Android's wrap_content.

Sometimes I get rendering Exceptions because the framework can't calculate the size of a widget, as when using Row and Column together, as explained here. The solution presented is always to use Expanded, but what if I don't want that content to expand? What if I want it as small as it can be without clipping anything?

The solution is usually to use multiple Expanded and Spacer with different flex parameters, but still this isn't perfect as negotiating flex values isn't what we always want, as the Spacer will not vanish if the screen gets smaller, it will try to maintain it's proportionality, forcing my widget to get smaller.

Maybe I am missing something about the way the framework works, so then this would be lack of tutorials, or maybe the Framework is missing a ShrinkWrap widget (as this is a property of some widgets already) or something with a similar name, that will size the wrapped widget to be as small as it can be.

Example of a problem that could benefit from this here, as I couldn't find how to solve this, even with IntrinsicHeight.

Metadata

Metadata

Assignees

No one assigned

    Labels

    P3Issues that are less important to the Flutter projectc: new featureNothing broken; request for a new capabilityc: proposalA detailed proposal for a change to Flutterframeworkflutter/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