Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Slight change for Chip text #322

Closed
MahdiBaghbani opened this issue May 7, 2022 · 2 comments
Closed

Slight change for Chip text #322

MahdiBaghbani opened this issue May 7, 2022 · 2 comments
Labels
enhancement New feature or request

Comments

@MahdiBaghbani
Copy link

MahdiBaghbani commented May 7, 2022

I'm new to developing with flutter and my as first ever project I used your library, so this issue might be solved easier than I think,

Is your feature request related to a problem? Please describe.
I had to implement a list of users with full names and picture ID, so basically I copied Chip() exactly as it is from your example provided. sometimes user full names are too long, an as described in documents and stackoverflow I used Text() like this:

// simplified version
Chip(
  text: const Text(
    "A very very long string fetched from api",
    maxLines: 1,
   overflow: TextOverflow.ellipsis,
  ),
),

it didn't work, and then I tried other solutions like putting Text() inside Expanded() or Flexible(), which gives error.

// simplified version
Chip(
  text: const Expanded(
    child: Text(
      "A very very long string fetched from api",
      maxLines: 1,
      overflow: TextOverflow.ellipsis,
    ),
  ),
),

Describe the solution you'd like
following error messages generated by flutter I realized I cannot put Flexible() inside Padding() but I wasn't using any Padding().

Padding is done inside Chip()

if (text != null)
Padding(
padding: EdgeInsets.only(
right: spacing + visualDensity.horizontal),
child: text,
),

so I edited the file and added Flexible() here:

Flexible(
  child: Padding(
  padding: EdgeInsets.only(
    right: spacing + visualDensity.horizontal),
    child: text,
    ),
 )

now the Text() doesn't overflow anymore.

so I think it should be like that as default.

Describe alternatives you've considered
Nothing really.

Additional context
Is there and other way to make Text() not overflow?

@bdlukaa
Copy link
Owner

bdlukaa commented May 7, 2022

You can try to wrap the chip itself inside of a Flexible, if you're using a Row

@MahdiBaghbani
Copy link
Author

it is inside ListView.separated() which is inside Column(), I guess that's the problem.

@bdlukaa bdlukaa added the enhancement New feature or request label May 12, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants