Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Chip does not constrain size of children #11523

Copy link
Copy link

Description

@ameiyil
Issue body actions

Steps to Reproduce

I'm trying to utilize the Text widget's overflow properties when I put it into a chip.
However when I do the following the chip is not constraining the size of Text and results in the Text widget being wider than the available space*:

new Container(
  constraints: new BoxConstraints(maxWidth: 150.0),
  child: new Chip(
    label: new Text(
      'Some text that exceeds the width of parent',
      overflow: TextOverflow.ellipsis),
    onDeleted: myDeleteFunction
)

It produces the following:
screen shot 2017-08-04 at 3 06 55 pm

*putting 150.0 for illustrative purposes only, my main use case is this chip in a wrap

Current work around
Instead I need to do something like the following - where 38 represents the extra space on the "right" including the "x" icon since I always have a onDeleted function. This, unfortunately, requires me to hard-code the 38.

new Chip(
    label: new Container(
        constraints: new BoxConstraints(
            maxWidth: 150.0 - 38.0),
        child: new Text(email,
            overflow: TextOverflow.ellipsis)),
    onDeleted: myDeleteFunction,
)

Which works and gives me this:
screen shot 2017-08-04 at 3 07 08 pm

Request

Would it be possible for the label in Chip to be wrapped with an Expanded?
Something like this:

    children.add(new Expanded(
      child: new DefaultTextStyle(
        style: _kLabelStyle,
        child: label
      )
    ));
Reactions are currently unavailable

Metadata

Metadata

Assignees

No one assigned

    Labels

    f: material designflutter/packages/flutter/material repository.flutter/packages/flutter/material repository.frameworkflutter/packages/flutter repository. See also f: labels.flutter/packages/flutter repository. See also f: labels.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

    Morty Proxy This is a proxified and sanitized view of the page, visit original site.