Skip to content

[web]: BoxDecoration border doesn't render if borderRadius is set #37772

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

Closed
TheRealWelshCJ opened this issue Aug 7, 2019 · 5 comments · Fixed by flutter/engine#12229
Closed
Assignees

Comments

@TheRealWelshCJ
Copy link

TheRealWelshCJ commented Aug 7, 2019

If borderRadius is set within the Container BoxDecoration then it overwrites a border in the same BoxDecoration.

 Container(
          height: 100,
          width: 100,
          decoration: BoxDecoration(
            border: Border.all(color: Colors.orange, width: 2),
            borderRadius: BorderRadius.all(
               Radius.circular(10.0),
            ),
            color: Colors.green,
          ),
        ),

The code above is wrapped in a Row in the new flutter_web boiler plate.

In Chrome it looks like:
chrome1
if I comment out the borderRadius, then in chrome I get:

 Container(
          height: 100,
          width: 100,
          decoration: BoxDecoration(
            border: Border.all(color: Colors.orange, width: 2),
           // borderRadius: BorderRadius.all(
           //    Radius.circular(10.0),
           // ),
            color: Colors.green,
          ),
        ),

chrome2
The border seems to be being over written by the borderRadius in flutter_web.

The same code (as the first code block) on Android, produces this:

android

Chrome Version: Version 76.0.3809.100 (Official Build) (64-bit)

Webdev Version: 2.3.0

Command: flutter pub global run webdev serve --launch-in-chrome --auto refresh

Flutter_Web:

 flutter_web:
    dependency: "direct main"
    description:
      path: "packages/flutter_web"
      ref: HEAD
      resolved-ref: "88a6325290b75326c072ae63bf3016e15a08fccc"
      url: "https://github.com/flutter/flutter_web"
    source: git
    version: "0.0.0"
  flutter_web_ui:
    dependency: "direct main"
    description:
      path: "packages/flutter_web_ui"
      ref: HEAD
      resolved-ref: "88a6325290b75326c072ae63bf3016e15a08fccc"
      url: "https://github.com/flutter/flutter_web"
    source: git
    version: "0.0.0"
@TheRealWelshCJ
Copy link
Author

Potential duplicates:

#37121
#32893
#34201 (closed due to lack of information)

@ditman ditman self-assigned this Sep 11, 2019
@ditman
Copy link
Member

ditman commented Sep 11, 2019

Checking

@ditman
Copy link
Member

ditman commented Sep 11, 2019

The problem is that drawDRRect checks if the inner rectangle (in this case, the inner side of the border) is contained within the outer rectangle (the outer side of the border), here.

It seems the check above is not correct, since it's not taking into account inner's radius when checking, so DRRects that have a "thin" border width compared to its border radius (less than ~1/3rd, on circular radii) will fail the check (and not render the border).

(For reference, this is the implementation of RRect.contains, which does take into account the normalized border radius to compute if a point is contained within the rrect)

@ditman
Copy link
Member

ditman commented Sep 11, 2019

The inner part is computed by calling .deflate on the outer part (by the width of the border).

Deflate just substracts from both the coordinates of the rectangle, and its corner radius.

I'm going to try a fix by changing the contains method by something that looks just at the coordinates of the rectangle and its radius.

ditman added a commit to flutter/engine that referenced this issue Sep 17, 2019
… outer on RecordingCanvas (#12229)

* Improve check to determine if a rrect is fully contained within another in RecordingCanvas.
* Add unit tests.

Fixes flutter/flutter#37772 (and others)
@github-actions
Copy link

This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of flutter doctor -v and a minimal reproduction of the issue.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 28, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants