-
Notifications
You must be signed in to change notification settings - Fork 28.7k
Add DropdownTheme
for DropdownButton
and DropdownButtonFormField
#104211
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
a87c70e
to
b0f08d8
Compare
cc: @Piinks Once this is merged, I will add a replacement for I found that the |
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 is wonderful!
I am curious about theme conventions for some of those static methods.
Since this is net new, we have the opportunity to make sure we pick the pattern we want to stick with moving forward.
@HansMuller @darrenaustin do you have any opinion on this?
/// Overrides the default value of [DropdownButton.iconEnabledColor], | ||
/// [DropdownButton.iconDisabledColor], [DropdownButtonFormField<T>.iconEnabledColor] | ||
/// and [DropdownButtonFormField<T>.iconDisabledColor]. |
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.
Oooo these looks like potential deprecations in the future to migrate to a material state property? @darrenaustin is that true?
} | ||
|
||
/// Linearly interpolate between DropdownThemeData objects. | ||
static DropdownThemeData? lerp(DropdownThemeData? a, DropdownThemeData? b, double t) { |
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.
Why can this return null? I have looked at a few different examples like the switch theme and checkbox theme and they do not do this. However, I do know there is some variance between theme classes based on new and old preferred patterns. Was there a class you were using as a model 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.
Oh I just saw ButtonStyle is similar, that is certainly newer. I wonder if there is a chance to create more consistency in these theme patterns. (Likely a separate issue :) )
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.
We are definitely not consistent about the return value when both parameters are null. Returning a non-null theme data value in that case does seem odd though. We should be (become) consistent.
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 haven't reviewed the tests but this looks pretty good to me.
} | ||
|
||
/// Linearly interpolate between DropdownThemeData objects. | ||
static DropdownThemeData? lerp(DropdownThemeData? a, DropdownThemeData? b, double t) { |
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.
We are definitely not consistent about the return value when both parameters are null. Returning a non-null theme data value in that case does seem odd though. We should be (become) consistent.
b0f08d8
to
8e4d2c1
Compare
Once this is merged, I will add support for the Material 3 dropdown menu using menu tokens with the theme defaults. Already did for the Popup menu. |
CC @gspencergoog |
What is the status of this PR? @gspencergoog given @HansMuller's last comment do you have any input here as it relates to menus? Or is this ok to proceed? |
I think unifying the menu architecture is something where we need to have some discussions and planning, and those haven't happened yet. I suspect that we will want some unification, but I can't say for sure yet what that will be. As for this PR, I suspect that we will still want a separate theme for the Dropdown button, but if Hans thinks we should wait, then perhaps we should just close this PR for now and revive it when we have a plan. |
This was a good first cut, given the current menu tech in Flutter, however I think we should wait until the new menu system lands and we've decided how that will change the dropdown classes (#104211 (comment)). I'm going to close this PR for now; we'll revisit in a few weeks when the new menu system has landed. |
Hi, what is the status of the dropdownMenu Theme? |
Please try the M3 DropdownMenu. It's a newer version of DropdownButton and supports theming using DropdownMenuTheme |
fixes #98695
minimal code sample
Pre-launch Checklist
///
).If you need help, consider asking for advice on the #hackers-new channel on Discord.