-
Notifications
You must be signed in to change notification settings - Fork 29.7k
Allow null DropdownButton values #6971
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
| children: config.items | ||
| // The button's size is defined by its largest menu item. If value is | ||
| // null then an item does not appear. | ||
| new Opacity( |
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 use an opacity here? I guess that works, but I would have expected there to be a more direct way of making a subtree take up space but be invisible.
In particular, the children can still be hit with opacity 0.0, but presumably that's not what you want.
| new Opacity( | ||
| opacity: _selectedIndex == null ? 0.0 : 1.0, | ||
| child: new IndexedStack( | ||
| index: _selectedIndex ?? 0, |
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.
Maybe you should teach indexedstack to take a null index, which means "show none of the children"
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.
Sure, sounds good, I'll do that.
| /// from displaying their underlines. | ||
| /// * [RaisedButton], [FlatButton], ordinary buttons that trigger a single action. | ||
| /// * <https://material.google.com/components/buttons.html#buttons-dropdown-buttons> | ||
| class DropdownButton<T> extends StatefulWidget { |
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.
at some point we should document T here and in the related classes (not necessarily in this PR unless you're feeling particularly heroic)
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 will put it on my TODO list.
Specifying null as the DropdownButton's value causes the dropdown to appear empty until a selection is made.
If the dropdown is added to an InputContainer, a hint and label can be displayed as well.
Changed IndexedStack: specifying index: null prevents the widget from displaying anything or responding to input.
Fixes #6422
Here's an example that demos this feature along with InputContainer.