Skip to content

Conversation

@sahandevs
Copy link
Contributor

Description

added clipBehaviour to Container

if (clipBehaviour != null &&
        clipBehaviour != Clip.none &&
        decoration is BoxDecoration) {
      final BoxDecoration _decoration = decoration;
      current = ClipRRect(
        borderRadius: _decoration.borderRadius,
        clipBehavior: clipBehaviour,
        child: current,
      );
    }

i did cast the decoration to BoxDecoration because i need access to the borderRadius for the ClipRRect

Related Issues

resolves #14421

Checklist

  • I read the Contributor Guide and followed the process outlined there for submitting PRs.
  • I signed the CLA.
  • I read and followed the Flutter Style Guide, including Features we expect every widget to implement.
  • I updated/added relevant documentation (doc comments with ///).
  • All existing and new tests are passing.
  • The analyzer (flutter analyze --flutter-repo) does not report any problems on my PR.
  • I am willing to follow-up on review comments in a timely manner.

Breaking Change

Does your PR require Flutter developers to manually update their apps to accommodate your change?

  • Yes, this is a breaking change (Please read Handling breaking changes). Replace this with a link to the e-mail where you asked for input on this proposed change.
  • No, this is not a breaking change.

@fluttergithubbot
Copy link
Contributor

It looks like this pull request may not have tests. Please make sure to add tests before merging. If you need an exemption to this rule, contact Hixie.

Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing.

@fluttergithubbot fluttergithubbot added the framework flutter/packages/flutter repository. See also f: labels. label Oct 26, 2019
Copy link
Contributor

@Piinks Piinks left a comment

Choose a reason for hiding this comment

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

Hi @sahandevs,
Welcome! and thank you for the contribution! 🎉
This change will need a test to ensure the behavior you are adding matches expectations.


/// The transformation matrix to apply before painting the container.
final Matrix4 transform;
/// clipBehaviour for [BoxDecoration.borderRadius]
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: blank line above this, and a full sentence description

Suggested change
/// clipBehaviour for [BoxDecoration.borderRadius]
/// clipBehaviour for [BoxDecoration.borderRadius]

@sahandevs
Copy link
Contributor Author

sahandevs commented Oct 30, 2019

Hi @Piinks, Thanks!

I added some tests and fixed the doc.

final Matrix4 transform;

/// The clip behaviour when [BoxDecoration.borderRadius] is available.
///
Copy link
Member

Choose a reason for hiding this comment

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

nit: there's a trailing whitespace here that should be removed.


if (clipBehaviour != null &&
clipBehaviour != Clip.none &&
decoration is BoxDecoration) {
Copy link
Member

Choose a reason for hiding this comment

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

It's strange that the clipping will only work for BoxDecorations. What about a ShapeDecoration? Or any other decoration?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

we need to access the borderRadius inside the decoration

  • We can just check for BoxDecoration ( Wich will support must use cases )
  • Or We can create interface like ShapeWithBorder and add it to the all decorations
  • Or we can just add another property in the Container as 'borderRadius' and use that

Wich one do you think is the best? @goderbauer

Copy link
Member

Choose a reason for hiding this comment

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

We should ensure that this works for all decorations. We probably need to add something to the Decoration base class to get a clipPath (similar to ShapeBorder.getOutterPath) and then use that here.

@Piinks Piinks added the c: new feature Nothing broken; request for a new capability label Nov 4, 2019
@Piinks
Copy link
Contributor

Piinks commented Nov 11, 2019

Hi @sahandevs, are you planning on returning to this? It looks like the analyzer has detected whitespace in your changes.

@sahandevs
Copy link
Contributor Author

@Piinks I'm waiting for @goderbauer response

@sahandevs
Copy link
Contributor Author

@goderbauer I've added getBorderRadius to Decoration class and implemented it in BoxDecoration and ShapeDecoration if this approach is OK I will add docs and some tests for it

this.image,
this.gradient,
this.shadows,
this.borderRadius,
Copy link
Member

Choose a reason for hiding this comment

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

Adding a borderRadius here doesn't make much sense - especially since the class just seems to ignore it.

Copy link
Member

Choose a reason for hiding this comment

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

Instead, a shapeDecoration should be clipped to its shape.

/// if it is a [BoxDecoration] with definitely no [DecorationImage]).
BoxPainter createBoxPainter([ VoidCallback onChanged ]);

BorderRadius getBorderRadius() => null;
Copy link
Member

Choose a reason for hiding this comment

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

Not all decorations have a border radius. This will probably have to return a more generic clip Path.

@goderbauer
Copy link
Member

Also: to fix the tests you'll have to merge the latest master into your PR.

@sahandevs sahandevs requested a review from jmagman as a code owner November 15, 2019 06:13
…tches, checkboxes, and radio buttons. (#43384)" (#43647)"

This reverts commit e6d9009.
…heckboxes, and radio buttons. (#43384)"

This reverts commit cc6f7e8.
@googlebot
Copy link

All (the pull request submitter and all commit authors) CLAs are signed, but one or more commits were authored or co-authored by someone other than the pull request submitter.

We need to confirm that all authors are ok with their commits being contributed to this project. Please have them confirm that by leaving a comment that contains only @googlebot I consent. in this pull request.

Note to project maintainer: There may be cases where the author cannot leave a comment, or the comment is not properly detected as consent. In those cases, you can manually confirm consent of the commit author(s), and set the cla label to yes (if enabled on your project).

ℹ️ Googlers: Go here for more info.

@sahandevs
Copy link
Contributor Author

I Created a new pull request because of the mess #44971

@sahandevs sahandevs closed this Nov 15, 2019
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 3, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

c: new feature Nothing broken; request for a new capability framework flutter/packages/flutter repository. See also f: labels.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add Container.clipBehavior to clip to the decoration

5 participants