-
Notifications
You must be signed in to change notification settings - Fork 29.7k
Fix OutlineInputBorder with BorderRadius.zero is distorted #106849
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
Fix OutlineInputBorder with BorderRadius.zero is distorted #106849
Conversation
75846ed to
952621b
Compare
|
Hey @justinmc! |
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.
clampRadius could be a better name
ec1e8ea to
589885f
Compare
|
@justinmc |
|
If Justin is unavailable, you could try asking @gspencergoog for a review. He usually enjoys reviewing borders. |
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.
Shouldn't we do this in RRect.deflate/inflate (because deflate uses inflate with a negative value)? Or at least assert there when any of the radii go below zero?
There may be performance implications for actually clamping it there, but we shouldn't be asking for/allowing negative radii anyhow. RRect could assert, but also provide an inflate/deflate method that clamps radii (and suggest using that in the assert message).
(I've asked on Discord to see if there's a reason we don't already do this)
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 added a draft PR (flutter/engine#36062) to see if anything blows up when we try 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.
In talking to others about this, the consensus was that clamping is just a couple of instructions and we should just do the right thing. flutter/engine#36062 does clamping in deflate/inflate, and asserts if an RRect is created with a negative radius. As soon as the tests pass there, I'll move it to a non-draft PR, and then you can base this change on top of that (which should eliminate some of the code you needed to write).
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.
Man. OK, so in order to assert that there aren't any negative radii given to RRect, I first need to have an easy way to clamp them, and add that into the Flutter repo code before I can merge the change that causes asserts when RRect gets a negative radius, so this is going to be a multi-step process to do the right thing. flutter/engine#36106
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.
Great! I will update this PR as soon as flutter/engine#36062 and flutter/engine#36106 will land.
589885f to
d7f09fb
Compare
d7f09fb to
1776a0c
Compare
|
@bleroux OK, I've moved the |
@gspencergoog That’s great to have RRect clamping at the engine level 👍 |
gspencergoog
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.
|
@bleroux Sorry for missing this PR and thanks @gspencergoog for reviewing! |

Description
This PR fixes an
OutlineInputBorderrendering bug. WhenOutlineInputBorder.borderRadiusisBorderRadius.zeroand the parentInputDecorator.labelTextis set and shown on the border, the border is drawn usingCanvas.drawPathand the path is distorted.There were some miscalculations mainly related to using a temporary
RRectwith negative border radii.This PR
adds a privatebuilds the path without calling_clampRadiusmethod to clamp negative border radii andPath.addArcfor corners with a zero border radius.Edit:
RRectradii clamping was added to the engine (see flutter/engine#36062 and flutter/engine#36106).Before this PR (and before flutter/engine#36062 + flutter/engine#36106) :

Before this PR (and after flutter/engine#36062 + flutter/engine#36106) :

After :

Related Issue
Fixes #78855
Fixes #111086
Tests
Adds 1 test.