-
Notifications
You must be signed in to change notification settings - Fork 27.9k
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
Add padding to DropdownButton #115806
Add padding to DropdownButton #115806
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.
Hey @davidskelly, welcome! Thanks for contributing!
This looks like a bug that should work automatically instead of having the user fix it through a padding
parameter. Can you remove the padding parameter and just adding the padding in the widget so the space is correct?
Hi @Piinks - I added some sample code to the linked issue - . But what I meant to describe was - In the first image I have a custom Container (that adds the outline) with padding (padding: EdgeInsets.symmetric(horizontal: 20)) around the DropdownButton, but the blue shows the smaller hitbox: Without the Container padding, it looks like this: So to get to the padded container with the correct size hitbox, the DropdownButton needs the padding passed in: |
This pull request executed golden file tests, but it has not been updated in a while (20+ days). Test results from Gold expire after as many days, so this pull request will need to be updated with a fresh commit in order to get results from Gold. 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. |
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 @davidskelly for updating, and sorry this one fell off my radar! Can you take a look at the failing analyzer check here?
@Piinks - updated test! |
@@ -1128,6 +1130,11 @@ class DropdownButton<T> extends StatefulWidget { | |||
/// instead. | |||
final Color? dropdownColor; | |||
|
|||
/// Padding of this widget. |
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.
What part of the widget?
How is this different from the user just wrapping the items
in padding?
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.
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.
How is this different from the user just wrapping the items in padding?
The popup menu already adds a padding to the box. If items
are wrapped in a Padding
, it produces a weird effect in the popup (yet, looking good on the button). On the other hand, if no Padding
is added, the popup looks good, but the button does not.
I believe that adding the same padding added to the popup menu to the button is a good fix for the issue, which is what this PR does
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.
This documentation is still lacking some more context from my first comment here. :)
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.
Pushed a change to update the documentation.
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! It isn't actually the padding around the button though, is it? It is inside of the button.
The docs should still also include an explanation of how this is different from just wrapping the button, or the content of the button, in a Padding widget. As well as, how does the padding affect the overall size of the button?
All of the things we have been discussing in this PR make for helpful documentation for developers. :)
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.
Added some more detail to the documentation.
@Piinks is there anything else you need from me here? |
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, thank you. This will need a second reviewer, I will seek one out.
The change LGTM, but I think it's worth mentioning for future readers that the custom Material 3 widget I'd highly recommend using that widget over |
Add a padding param to DropdownButton. The current clickable hitbox looks like this when using external padding:
This allows the hitbox to look like this:
Fixes #115793
If you had to change anything in the flutter/tests repo, include a link to the migration guide as per the breaking change policy.
Pre-launch Checklist
///
).If you need help, consider asking for advice on the #hackers-new channel on Discord.