-
Notifications
You must be signed in to change notification settings - Fork 29.7k
Description
Is there an existing issue for this?
- I have searched the existing issues
- I have read the guide to filing a bug
Use case
I encountered this today while working on our Flutter app, and was confused for a minute at the behaviour I saw (aka not great dev ex). The ActionChip constructor documentation is clear:
/// ...
/// The [label], [onPressed], [autofocus], and [clipBehavior] arguments must
/// not be null. ...Got it, onPressed must be non-null. Yet the type of onPressed is VoidCallback? and the argument is not required in the constructor, nor is there a constructor assert. When you leave it out, the ActionChip has a very non-intuitive background color, which turns out to be the disabled state. This is actually written about in the class documentation:
/// ... For Material 3, a disabled state is supported for Action
/// chips and is specified with [onPressed] being null. For previous versions
/// of Material Design, it is recommended to remove the Action chip from
/// the interface entirely rather than display a disabled chip.So it is allowed to be null. That makes the constructor documentation wrong.
Proposal
The intention here seems to me that onPressed should always be set, unless the user desires a disabled state. Thus it would make sense to me to make the onPressed required in the constructor, that makes it intentional. Then, I'd suggest amending the constructor documentation to no longer say that onPressed should be non-null. Happy to make a PR.
Metadata
Metadata
Assignees
Labels
Type
Projects
Status