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
Add Non-Uniform Border to Border. #121921
Conversation
2c66e80
to
8e822a2
Compare
9c63189
to
7dfad4b
Compare
@@ -567,7 +632,7 @@ class Border extends BoxBorder { | |||
assert(() { | |||
if (!_strokeAlignIsUniform || top.strokeAlign != BorderSide.strokeAlignInside) { | |||
throw FlutterError.fromParts(<DiagnosticsNode>[ | |||
ErrorSummary('A Border can only draw strokeAlign different than BorderSide.strokeAlignInside on uniform borders.'), | |||
ErrorSummary('A Border can only draw strokeAlign different than BorderSide.strokeAlignInside on borders with uniform colors.'), |
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
@@ -567,7 +632,7 @@ class Border extends BoxBorder { | |||
assert(() { | |||
if (!_strokeAlignIsUniform || top.strokeAlign != BorderSide.strokeAlignInside) { | |||
throw FlutterError.fromParts(<DiagnosticsNode>[ | |||
ErrorSummary('A Border can only draw strokeAlign different than BorderSide.strokeAlignInside on uniform borders.'), | |||
ErrorSummary('A Border can only draw strokeAlign different than BorderSide.strokeAlignInside on borders with uniform colors.'), |
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.
@@ -538,15 +578,25 @@ class Border extends BoxBorder { | |||
} | |||
} | |||
|
|||
// Allow painting non-uniform borders if the color is 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.
// 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.
// Allow painting non-uniform borders if the color is uniform. | ||
// | ||
// See also: | ||
// * <https://pub.dev/packages/non_uniform_border>, a package that |
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?).
end: BorderSide(width: 15, strokeAlign: BorderSide.strokeAlignOutside), | ||
bottom: BorderSide(width: 20), | ||
); | ||
expect(nonUniformBorderDirectional.dimensions, const EdgeInsetsDirectional.fromSTEB(5, 5, 0, 20)); |
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? |
a85d907
to
48337da
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.
@@ -212,7 +212,8 @@ abstract class BoxBorder extends ShapeBorder { | |||
/// | |||
/// See also: | |||
/// | |||
/// * [paintBorder], which is used if the border is not uniform. | |||
/// * [paintBorder], which is used if the border has non-uniform colors or styles and no borderRadius. | |||
/// * [Border.paint], which is the similar method in [Border] with additional comments. |
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.
What do you mean by "additional comments"? More context? I'd reword this in any case.
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.
Yes. I'll reword. BorderDirectional is shorter and gives less detail on what each parameter do than the equivalent Border.
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. Replacement is:
[Border.paint], similar to this method, includes additional comments and provides more details on each parameter than described here.
900dcf3
to
acf8bef
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.
LGTM
acf8bef
to
72be3b9
Compare
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.