-
Notifications
You must be signed in to change notification settings - Fork 29.7k
Remove ClipRect from Snackbar
#94811
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
|
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 on the #hackers channel in Chat. If you are not sure if you need tests, consider this rule of thumb: the purpose of a test is to make sure someone doesn't accidentally revert the fix. Ask yourself, is there anything in your PR that you feel it is important we not accidentally revert back to how it was before your fix? Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing. |
|
cc: @Piinks I can see ClipRect was added in https://github.com/flutter/flutter/pull/66504/files#diff-f28e065ae18b9a43c269b6b6e56ceb417084872226ea345fd3e3e207837f0f3dR563 Is it necessary for Hero transition? Is this a good change? If you have any alternative fix |
|
Gold has detected about 6 new digest(s) on patchset 1. |
|
Golden file changes have been found for this pull request. Click here to view and triage (e.g. because this is an intentional change). If you are still iterating on this change and are not ready to resolve the images on the Flutter Gold dashboard, consider marking this PR as a draft pull request above. You will still be able to view image results on the dashboard, commenting will be silenced, and the check will not try to resolve itself until marked ready for review. For more guidance, visit Writing a golden file test for Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing. |
|
I don't think it was necessary for the Hero, the ClipRect was already there before I made that change. |
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.
I am not sure why there was a ClipRect there to begin with, I would look in the git history to see if it was intentional so we don't introduce a regression.
There is a duplicate issue that is closed:
It was fixed by:
So either we regressed already, or the bug was never fixed and was closed accidentally (those PRs all appear to be related to positioning). In either case, we should add more explicit tests so we know for sure if this comes up again in the future.
|
@Piinks I already looked into #47202 and its PRs, it seems to be a related position indeed and it shows shadow being clipped at the bottom by navigation but the new issue is only reproducible when you force a width and horizontal sides are clipped (this parameter wasn't available in that version of Fluttter where this was handled). This seems to be a common issue that also affects other widgets with elevation too Here I created a basic code sample that doesn't use Snackbar at all, just to demonstrate what's happening with minimal code sampleimport 'package:flutter/material.dart';
void main() => runApp(const MyApp());
class MyApp extends StatelessWidget {
const MyApp({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return const MaterialApp(
title: 'Material App',
home: Home(),
);
}
}
class Home extends StatelessWidget {
const Home({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Text('Material App Bar'),
),
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [
ClipRect(
child: Container(
margin: const EdgeInsets.only(bottom: 15, top: 10),
width: 300,
child: const Material(
elevation: 8,
shape: RoundedRectangleBorder(),
child: Padding(
padding: EdgeInsets.all(8.0),
child:
Text('ClipRect > Container(width: 300) > Material'),
)),
),
),
Container(
margin: const EdgeInsets.only(bottom: 15, top: 10),
width: 300,
child: const Material(
elevation: 8,
shape: RoundedRectangleBorder(),
child: Padding(
padding: EdgeInsets.all(8.0),
child: Text('Container(width: 300) > Material'),
)),
),
ClipRect(
child: Container(
margin: const EdgeInsets.only(bottom: 15, top: 10, left: 15, right: 15),
child: const Material(
elevation: 8,
shape: RoundedRectangleBorder(),
child: Padding(
padding: EdgeInsets.all(8.0),
child: Text('Container with horizontal margins > Material'),
)),
),
),
],
),
),
);
}
}
|
| return Hero( | ||
| tag: '<SnackBar Hero tag - ${widget.content}>', | ||
| child: ClipRect(child: snackBarTransition), | ||
| child: Container(child: snackBarTransition), |
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 we just remove the Container?
|
Gold has detected about 10 new digest(s) on patchset 2. |
|
Golden file changes are available for triage from new commit, Click here to view. For more guidance, visit Writing a golden file test for Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing. |
|
@Piinks |
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 @TahaTesser! I am surprised the analyzer did not complain about an empty Container wrapper.
This and the golden files LGTM! The bot does not recognize that those are tests, I'll reach out to @Hixie for exception. :)
|
test-exempt: is tested (gold) Looks like this also breaks some Google-internal tests, you'll need to ask someone to take a look at those to see if it's anything serious or just more golden tests. Ask around in #hackers-tests. |
|
Thanks @Hixie! I have taken a look at the Google-internal failures. They all look as expected, there is just a sliver of shadow that was previously being clipped incorrectly, similar to the golden file updates here. |
ClipRect in Snackbar with a Container for Clip.none clip behaviorClipRect from Snackbar
|
If there is a BackdropFilter involved it will suddenly blur the entire screen rather than just the contents under the widget. As per BackdropFilter:
In fact, this change caused a customer issue of this exact nature: #98205 |

Fixes #94701
Complete details #94701 (comment)
Based on this feedback, I notice a lot of inner
snackbarwidget instances already haveclip.noneas default, and I also tried the material widget with a container forclip.noneyet the clipping was not going away then I realized,ClipRectis actually the widget that is doing this clipping here. Replacing this widget with a simple container solves the clipping but it does affect a few golden tests as expected.Golden "material.snack_bar.goldenTest.workWithBottomSheet.png": Pixel test failed, 0.16% diff detected.Pre-launch Checklist
///).If you need help, consider asking for advice on the #hackers-new channel on Discord.