Thanks to visit codestin.com
Credit goes to github.com

Skip to content

fix overflow error in CupertinoListTile #113010

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

Merged
merged 3 commits into from
Oct 17, 2022
Merged

Conversation

alex-sandri
Copy link
Contributor

@alex-sandri alex-sandri commented Oct 6, 2022

See #78732 (comment) for more details.

This PR fixes an overflow error in the CupertinoListTile widget.

Closes #108910.

Pre-launch Checklist

  • I read the Contributor Guide and followed the process outlined there for submitting PRs.
  • I read the Tree Hygiene wiki page, which explains my responsibilities.
  • I read and followed the Flutter Style Guide, including Features we expect every widget to implement.
  • I signed the CLA.
  • I listed at least one issue that this PR fixes in the description above.
  • I updated/added relevant documentation (doc comments with ///).
  • I added new tests to check the change I am making, or this PR is test-exempt.
  • All existing and new tests are passing.

Before

before

After

after

@flutter-dashboard flutter-dashboard bot added f: cupertino flutter/packages/flutter/cupertino repository framework flutter/packages/flutter repository. See also f: labels. labels Oct 6, 2022
@alex-sandri alex-sandri marked this pull request as ready for review October 6, 2022 08:04
@MitchellGoodwin MitchellGoodwin self-requested a review October 6, 2022 16:15
Copy link
Contributor

@MitchellGoodwin MitchellGoodwin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi, thank you for putting this together. Because of the maxLines property in the text styles, like the one on line 285 of the list tile file, this would cause this change to not throw an error if there's an overflow, but it would keep the text to one line and not wrap. I think the Spacer also fulfills a role of making multiple tiles that have different content (i.e. additionalContent, trailing, and leading) look uniform, and I'm concerned taking it out would make the typical case of the title not needing to wrap look worse. Would you be able to play around with that? It would be helpful if you posted before and after screenshots as well, to make it easy to review.

@alex-sandri
Copy link
Contributor Author

Hi @MitchellGoodwin, I attached before and after screenshots in the original PR comment but I'm not quite sure what you mean with this comment relative to removing the Spacer

I'm concerned taking it out would make the typical case of the title not needing to wrap look worse.

Anyways as you can see from the screenshots this PR does not change the behavior or layout of the widget in any way. Regarding the text wrapping I'm not sure if that should be the default behavior as in iOS, from what I've seen, the current behavior of setting maxLines to 1 is the expected one (it is still possible for a developer to override this by providing a new DefaultTextStyle above the actual title or subtitle).

I think the best solution to this would be to set the DefaultTextStyle's overflow property to TextOverflow.ellipsis (Lines 283 and 303).

Example of overriding the default maxLines value for the title widget:

title: Builder(
  builder: (context) {
    return DefaultTextStyle(
      style: DefaultTextStyle.of(context).style,
      maxLines: 2,
      child: Text('Title'),
    );
  },
),

@MitchellGoodwin
Copy link
Contributor

Ok, I was seeing some weird behavior with a lot of text added when I removed the spacer and removed the maxLines value. I thought the intention was to allow for text wrapping by default because of the issue, but I like the idea of leaving it set to a max line of one, and letting the developer override themselves.

Could you add the TextOverflow.ellipsis? I think that will be important for showing we are intending to cut text off at one line. After that, I think this will be good to go.

@alex-sandri
Copy link
Contributor Author

@MitchellGoodwin Done! And yeah looking back at the issue I see I originally expected it to wrap so sorry for the confusion.

Copy link
Contributor

@MitchellGoodwin MitchellGoodwin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Contributor

@justinmc justinmc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍 Thanks for the fix!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
autosubmit Merge PR when tree becomes green via auto submit App f: cupertino flutter/packages/flutter/cupertino repository framework flutter/packages/flutter repository. See also f: labels.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

CupertinoListTile overflow error
3 participants