-
Notifications
You must be signed in to change notification settings - Fork 29.3k
Fix ExpansionTile
splash effect
#135855
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 ExpansionTile
splash effect
#135855
Conversation
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
Note: it's clear that this PR fixes the reported problem. What about other shapes? StadiumBorder for an obvious example.
That's a good point. Unfortunately, It's not easy to retrieve to border radius from Overall, I'm not happy with this current PR implementation just catering to one shape. |
3284360
to
10a4003
Compare
FYI, I also marked existing |
I think it's OK to land this, since it fixes a common case. However please open an issue and a TODO in the code per your comment: #135855 (comment) |
1ca73d6
to
c322d2b
Compare
@HansMuller |
Looks like this is failing "Google Testing" |
Interesting! Appreciate the help. |
@TahaTesser - The developer took a look at the test failures; replacing the ExpansionTile's Container with an Ink widget is definitely a breaking change. Could the ExpansionTile widget just create its own Material? That's how the button classes ensure that the background and ink splash are clipped to the button's shape. |
We've stayed from adding I've made a similar fix using the flutter/packages/flutter/lib/src/material/list_tile.dart Lines 856 to 863 in 4f959b9
I think the performance reasons to not add cc: @Piinks We've discussed this and agreed to not add |
I might be able to figure something out if you could please share the test case (test code sample) that's breaking. |
Not sure if a test case is forthcoming, will ask though. @Piinks suggested only creating a Material widget per ExpansionTile when a shape was specified. That might mitigate the performance impact a little. Assuming there still is a performance penalty for creating extra Material widgets and that lazy list rendering doesn't suffice to overcome whatever penalty that is. |
This will be great if we can mitigate the performance penalty. Adding
|
16d9f25
to
267511c
Compare
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. Changes reported for pull request #135855 at sha 267511c50a1989f626540ed696eeed164b1c31b0 |
I've implemented the changes. please take a look. |
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.
Is the Container necessary when isShapeProvided
is true?
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.
Thank you! Great point. I found something important with your comment. We need border side padding even for Material
widget when a custom shape is provided.
Container
's decoration adds padding for the top and bottom border sides.
Here you can see total height is 50px (48px + 1px (top) + 1px (bottom))
With just DecoratedBox
, there is no such border side padding.
This illustrates what's happening. We want the bottom behavior for both default and custom shapes.
To fix this I have wrapped the column with a Padding
widget to fix the border side padding for default and custom shapes and replaced Container
with DecoratedBox
.
FYI, DecoratedBox
is needed for the background color.
35ad254
to
cd13c0a
Compare
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. Changes reported for pull request #135855 at sha 280636a0d9f83930402086ee6714a70d84b55713 |
280636a
to
c810a9e
Compare
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. Changes reported for pull request #135855 at sha f25c3a30dc59e0c3f73bfebe0019821a81aa9f6e |
f25c3a3
to
3a7209e
Compare
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. Changes reported for pull request #135855 at sha 3a7209e9eded21be0f2eb888911f17130a3680f0 |
3a7209e
to
2be38a9
Compare
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. Changes reported for pull request #135855 at sha 2be38a9edbb3320bd0822d932993083cec5c607f |
Update on this This is most likely to be reverted just like multiple recent PRs with ink sparkle golden tests from me and Bruno. I'm waiting for a workaround tried by @bleroux in #137998. If it works out, i will update the golden test in this PR otherwise remove it so it doesn't get reverted. |
For context, @Piinks raised a suspicion that these PRs had to be reverted due to randomness in the sparkle effect when testing for M3. |
FYI - confirmed the InkSparkle.constantTurbulenceSeedSplashFactory is the right way to eliminate randomness in testing. You can set it on the ThemeData for any relevant tests like in #137998 |
ead1dab
to
3180d4c
Compare
This comment was marked as resolved.
This comment was marked as resolved.
ce778c5
to
49a3fb2
Compare
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. Changes reported for pull request #135855 at sha 49a3fb2050bceb03fe7383e8182381a8ead0f24f |
49a3fb2
to
5fd143d
Compare
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. Changes reported for pull request #135855 at sha 5fd143dcabf68bfc04076358f365257c824f8c29 |
@HansMuller |
5fd143d
to
507c6a6
Compare
Closing this in favor of a fresh PR with clean history and golden files |
…plash ink (#141777) This updates the previous attempt #135855 and removes the complications when testing M3 ink sparkle effect. Thanks to this [PR](#138757) by @Piinks fixes [ExpansionTile InkSplash doesn't respect Shape's borderRadius](#125779) fixes [`ExpansionTile.backgroundColor` & `ExpansionTile.collapsedBackgroundColor` removes splash effect](#107113) ### Code sample <details> <summary>expand to view the code sample</summary> ```dart import 'package:flutter/material.dart'; void main() => runApp(const MyApp()); class MyApp extends StatelessWidget { const MyApp({super.key}); @OverRide Widget build(BuildContext context) { return const MaterialApp( debugShowCheckedModeBanner: false, home: Example(), ); } } class Example extends StatelessWidget { const Example({super.key}); @OverRide Widget build(BuildContext context) { return const Scaffold( body: Center( child: Padding( padding: EdgeInsets.symmetric(horizontal: 24.0), child: ExpansionTile( collapsedBackgroundColor: Color(0x25ff0000), backgroundColor: Color(0x250000ff), collapsedShape: RoundedRectangleBorder( borderRadius: BorderRadius.all(Radius.circular(30.0)), side: BorderSide(color: Colors.black, width: 2.0), ), shape: RoundedRectangleBorder( borderRadius: BorderRadius.all(Radius.circular(30.0)), side: BorderSide(color: Colors.black, width: 2.0), ), clipBehavior: Clip.hardEdge, title: Text('Expansion Tile'), children: <Widget>[ FlutterLogo(size: 50), FlutterLogo(size: 50), FlutterLogo(size: 50), FlutterLogo(size: 50), ], ), )), ); } } ``` </details> ### Before <img width="789" alt="Screenshot 2024-01-18 at 18 16 15" src="https://github.com/flutter/flutter/assets/48603081/8c6a6f1e-6986-4acf-8dec-e223a682c0d7"> <img width="789" alt="Screenshot 2024-01-18 at 18 16 44" src="https://github.com/flutter/flutter/assets/48603081/f55f6a26-2128-48a1-b24d-3c14e4f6ecdc"> ### After <img width="789" alt="Screenshot 2024-01-18 at 18 20 27" src="https://github.com/flutter/flutter/assets/48603081/7ec8b888-7319-460d-8488-9cd44c9246a6"> <img width="789" alt="Screenshot 2024-01-18 at 18 20 53" src="https://github.com/flutter/flutter/assets/48603081/80d66d5b-7eb2-4f47-ab4d-d7f469a731fa">
fixes ExpansionTile InkSplash doesn't respect Shape's borderRadius
fixes
ExpansionTile.backgroundColor
&ExpansionTile.collapsedBackgroundColor
removes splash effectCode sample
expand to view the code sample
Before
After
Pre-launch Checklist
///
).If you need help, consider asking for advice on the #hackers-new channel on Discord.