这是indexloc提供的服务,不要输入任何密码
Skip to content

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

Merged
merged 2 commits into from
Apr 9, 2021

Conversation

HansMuller
Copy link
Contributor

@HansMuller HansMuller commented Apr 8, 2021

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.

@flutter-dashboard flutter-dashboard bot added f: material design flutter/packages/flutter/material repository. framework flutter/packages/flutter repository. See also f: labels. labels Apr 8, 2021
@google-cla google-cla bot added the cla: yes label Apr 8, 2021
Copy link
Contributor

@darrenaustin darrenaustin left a 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].
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where is this enforced?

Copy link
Contributor Author

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].
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where is this enforced?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See above.

@HansMuller HansMuller merged commit 457985f into flutter:master Apr 9, 2021
@HansMuller HansMuller deleted the button_style_max_size branch April 9, 2021 15:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
f: material design flutter/packages/flutter/material repository. framework flutter/packages/flutter repository. See also f: labels.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants