-
Notifications
You must be signed in to change notification settings - Fork 29.7k
Add Non-Uniform Border to Border. #121921
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
Conversation
2c66e80 to
8e822a2
Compare
9c63189 to
7dfad4b
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
uniform colors/styles instead? Uniform colors is way more common and style == BorderStyle.none is kind of an invisible color.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But if we added a new border style, it might complicate things a lot. For instance, what if we added a "striped" border style that drew diagonal caution stripes? Or a "dashed" border style? I think it would be better if it were both color and style.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
4bdeb98 to
7575642
Compare
|
Hey @gspencergoog, did you miss me? 😛 |
11c6e01 to
a288699
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But if we added a new border style, it might complicate things a lot. For instance, what if we added a "striped" border style that drew diagonal caution stripes? Or a "dashed" border style? I think it would be better if it were both color and style.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| // Allow painting non-uniform borders if the color is uniform. | |
| // Allow painting non-uniform borders if the shape is rectangular, and the color and style are uniform. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I'll allow BoxShape.circle. I've been trying to deprecate it for 8 months, but that will give a reason for it to exist.
Let me see if I can implement non-uniform border for circles.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done. Making tests.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you move this "See also" to a real doc comment so people can see it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done, check if you prefer in Border or paint (probably paint, right?).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you also test to make sure that it asserts when non-uniform borders of various types are tried? You don't have to test for the assert message itself, but at least that it asserts under the right conditions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yessss. Hold on.
Of course! I love your PRs. :-) |
|
Do you think Edit: ignore it for now. I think the implementation will be ugly. |
Again, what happens if we add a new style? |
900dcf3 to
acf8bef
Compare
Piinks
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
acf8bef to
72be3b9
Compare
Re-implementation of PR #172441 <!-- Thanks for filing a pull request! Reviewers are typically assigned within a week of filing a request. To learn more about code review, see our documentation on Tree Hygiene: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md --> ## Add non-uniform border radius support to TableBorder This PR extends TableBorder to support border radius even when the outer border sides have different widths but the same color, similar to the non-uniform border support added to Border in #121921. ### Changes - Enhanced border rendering logic: TableBorder can now apply border radius when outer border sides have uniform colors but non-uniform widths/styles - New helper methods: Added `outerBorderIsUniform` property and `distinctVisibleOuterColors()` method to determine border uniformity - Optimized paint method: Refactored the paint logic to handle three scenarios: 1. Fully uniform borders (existing optimized path) 2. Outer borders with uniform colors but non-uniform widths (new non-uniform border radius support) 3. Completely non-uniform borders (fallback to standard border painting) ### Before/After - Before: TableBorder with border radius required all sides (including inner borders) to be completely identical. - After: TableBorder with border radius only requires outer border colors to be the same, allowing different widths per side. ### Example Usage ```dart TableBorder( top: BorderSide(color: Colors.blue, width: 3.0), right: BorderSide(color: Colors.blue, width: 1.0), // Different width bottom: BorderSide(color: Colors.blue, width: 2.0), // Different width left: BorderSide.none, // No border horizontalInside: BorderSide(color: Colors.red, width: 1.0), // Different color OK verticalInside: BorderSide(color: Colors.red, width: 1.0), // Different color OK borderRadius: BorderRadius.circular(8), // ✅ Now works! ) ``` Fixes: #173193 ## Pre-launch Checklist - [x] I read the [Contributor Guide] and followed the process outlined there for submitting PRs. - [x] I read the [Tree Hygiene] wiki page, which explains my responsibilities. - [x] I read and followed the [Flutter Style Guide], including [Features we expect every widget to implement]. - [x] I signed the [CLA]. - [x] I listed at least one issue that this PR fixes in the description above. - [x] I updated/added relevant documentation (doc comments with `///`). - [x] I added new tests to check the change I am making, or this PR is [test-exempt]. - [x] I followed the [breaking change policy] and added [Data Driven Fixes] where supported. - [x] All existing and new tests are passing. <!-- Links --> [Contributor Guide]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#overview [Tree Hygiene]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md [test-exempt]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#tests [Flutter Style Guide]: https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md [Features we expect every widget to implement]: https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md#features-we-expect-every-widget-to-implement [CLA]: https://cla.developers.google.com/ [flutter/tests]: https://github.com/flutter/tests [breaking change policy]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#handling-breaking-changes [Discord]: https://github.com/flutter/flutter/blob/main/docs/contributing/Chat.md [Data Driven Fixes]: https://github.com/flutter/flutter/blob/main/docs/contributing/Data-driven-Fixes.md
Re-implementation of PR flutter#172441 <!-- Thanks for filing a pull request! Reviewers are typically assigned within a week of filing a request. To learn more about code review, see our documentation on Tree Hygiene: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md --> ## Add non-uniform border radius support to TableBorder This PR extends TableBorder to support border radius even when the outer border sides have different widths but the same color, similar to the non-uniform border support added to Border in flutter#121921. ### Changes - Enhanced border rendering logic: TableBorder can now apply border radius when outer border sides have uniform colors but non-uniform widths/styles - New helper methods: Added `outerBorderIsUniform` property and `distinctVisibleOuterColors()` method to determine border uniformity - Optimized paint method: Refactored the paint logic to handle three scenarios: 1. Fully uniform borders (existing optimized path) 2. Outer borders with uniform colors but non-uniform widths (new non-uniform border radius support) 3. Completely non-uniform borders (fallback to standard border painting) ### Before/After - Before: TableBorder with border radius required all sides (including inner borders) to be completely identical. - After: TableBorder with border radius only requires outer border colors to be the same, allowing different widths per side. ### Example Usage ```dart TableBorder( top: BorderSide(color: Colors.blue, width: 3.0), right: BorderSide(color: Colors.blue, width: 1.0), // Different width bottom: BorderSide(color: Colors.blue, width: 2.0), // Different width left: BorderSide.none, // No border horizontalInside: BorderSide(color: Colors.red, width: 1.0), // Different color OK verticalInside: BorderSide(color: Colors.red, width: 1.0), // Different color OK borderRadius: BorderRadius.circular(8), // ✅ Now works! ) ``` Fixes: flutter#173193 ## Pre-launch Checklist - [x] I read the [Contributor Guide] and followed the process outlined there for submitting PRs. - [x] I read the [Tree Hygiene] wiki page, which explains my responsibilities. - [x] I read and followed the [Flutter Style Guide], including [Features we expect every widget to implement]. - [x] I signed the [CLA]. - [x] I listed at least one issue that this PR fixes in the description above. - [x] I updated/added relevant documentation (doc comments with `///`). - [x] I added new tests to check the change I am making, or this PR is [test-exempt]. - [x] I followed the [breaking change policy] and added [Data Driven Fixes] where supported. - [x] All existing and new tests are passing. <!-- Links --> [Contributor Guide]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#overview [Tree Hygiene]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md [test-exempt]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#tests [Flutter Style Guide]: https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md [Features we expect every widget to implement]: https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md#features-we-expect-every-widget-to-implement [CLA]: https://cla.developers.google.com/ [flutter/tests]: https://github.com/flutter/tests [breaking change policy]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#handling-breaking-changes [Discord]: https://github.com/flutter/flutter/blob/main/docs/contributing/Chat.md [Data Driven Fixes]: https://github.com/flutter/flutter/blob/main/docs/contributing/Data-driven-Fixes.md
Re-implementation of PR flutter#172441 <!-- Thanks for filing a pull request! Reviewers are typically assigned within a week of filing a request. To learn more about code review, see our documentation on Tree Hygiene: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md --> ## Add non-uniform border radius support to TableBorder This PR extends TableBorder to support border radius even when the outer border sides have different widths but the same color, similar to the non-uniform border support added to Border in flutter#121921. ### Changes - Enhanced border rendering logic: TableBorder can now apply border radius when outer border sides have uniform colors but non-uniform widths/styles - New helper methods: Added `outerBorderIsUniform` property and `distinctVisibleOuterColors()` method to determine border uniformity - Optimized paint method: Refactored the paint logic to handle three scenarios: 1. Fully uniform borders (existing optimized path) 2. Outer borders with uniform colors but non-uniform widths (new non-uniform border radius support) 3. Completely non-uniform borders (fallback to standard border painting) ### Before/After - Before: TableBorder with border radius required all sides (including inner borders) to be completely identical. - After: TableBorder with border radius only requires outer border colors to be the same, allowing different widths per side. ### Example Usage ```dart TableBorder( top: BorderSide(color: Colors.blue, width: 3.0), right: BorderSide(color: Colors.blue, width: 1.0), // Different width bottom: BorderSide(color: Colors.blue, width: 2.0), // Different width left: BorderSide.none, // No border horizontalInside: BorderSide(color: Colors.red, width: 1.0), // Different color OK verticalInside: BorderSide(color: Colors.red, width: 1.0), // Different color OK borderRadius: BorderRadius.circular(8), // ✅ Now works! ) ``` Fixes: flutter#173193 ## Pre-launch Checklist - [x] I read the [Contributor Guide] and followed the process outlined there for submitting PRs. - [x] I read the [Tree Hygiene] wiki page, which explains my responsibilities. - [x] I read and followed the [Flutter Style Guide], including [Features we expect every widget to implement]. - [x] I signed the [CLA]. - [x] I listed at least one issue that this PR fixes in the description above. - [x] I updated/added relevant documentation (doc comments with `///`). - [x] I added new tests to check the change I am making, or this PR is [test-exempt]. - [x] I followed the [breaking change policy] and added [Data Driven Fixes] where supported. - [x] All existing and new tests are passing. <!-- Links --> [Contributor Guide]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#overview [Tree Hygiene]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md [test-exempt]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#tests [Flutter Style Guide]: https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md [Features we expect every widget to implement]: https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md#features-we-expect-every-widget-to-implement [CLA]: https://cla.developers.google.com/ [flutter/tests]: https://github.com/flutter/tests [breaking change policy]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#handling-breaking-changes [Discord]: https://github.com/flutter/flutter/blob/main/docs/contributing/Chat.md [Data Driven Fixes]: https://github.com/flutter/flutter/blob/main/docs/contributing/Data-driven-Fixes.md
Fix #12583.
Fix #109954.
Exactly like Figma:
What if it has multiple colors + borderRadius? It will crash as usual.
Side effects: material data tables will paint faster, because drrect > path.