-
Notifications
You must be signed in to change notification settings - Fork 28.9k
Added ButtonStyle.maximumSize #80087
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
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.
I probably missed it, but I didn't see where the min < max size constraint is enforced. Is this handled by the BoxContraints
?
@@ -159,18 +160,29 @@ class ButtonStyle with Diagnosticable { | |||
/// | |||
/// The size of the rectangle the button lies within may be larger | |||
/// per [tapTargetSize]. | |||
/// | |||
/// This value must be less than or equal to [maximumSize]. |
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.
Where is this enforced?
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.
In the _ButtonStyleStat.build() expression that builds a BoxConstraints object:
BoxConstraints effectiveConstraints = resolvedVisualDensity.effectiveConstraints(
BoxConstraints(
minWidth: resolvedMinimumSize!.width,
minHeight: resolvedMinimumSize.height,
maxWidth: resolvedMaximumSize!.width,
maxHeight: resolvedMaximumSize.height,
),
);
If you pass invalid minimum/maximumSize values you get a pretty obvious error from the BoxConstraints constructor.
/// A [Size.infinite] or null value for this property means that | ||
/// the button's maximum size is not constrained. | ||
/// | ||
/// This value must be greater than or equal to [minimumSize]. |
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.
Where is this enforced?
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.
See above.
Added a ButtonStyle maximumSize property. Its default value is Size.infinite for TextButton, ElevatedButton, OutlinedButton, i.e. none of the buttons constrain their maximum size by default.