Skip to content

Conversation

@StanleyCocos
Copy link
Contributor

Add minWidth and minHeight to CupertinoButton to facilitate control over the minimum dimensions.

fix: #161294

Pre-launch Checklist

  • I read the [Contributor Guide] and followed the process outlined there for submitting PRs.
  • I read the [Tree Hygiene] wiki page, which explains my responsibilities.
  • I read and followed the [Flutter Style Guide], including [Features we expect every widget to implement].
  • I signed the [CLA].
  • I listed at least one issue that this PR fixes in the description above.
  • I updated/added relevant documentation (doc comments with ///).
  • I added new tests to check the change I am making, or this PR is [test-exempt].
  • I followed the [breaking change policy] and added [Data Driven Fixes] where supported.
  • All existing and new tests are passing.

@github-actions github-actions bot added framework flutter/packages/flutter repository. See also f: labels. f: cupertino flutter/packages/flutter/cupertino repository labels Jan 8, 2025
@victorsanni
Copy link
Contributor

Can we also add a dart fix to map current usage of minSize to minWidth and minHeight? This PR has an example of adding a dart fix.

Copy link
Contributor

@nate-thegrate nate-thegrate left a comment

Choose a reason for hiding this comment

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

I remember Justin mentioning that the material library's ButtonStyle has a minimumSize property, and it looks like its type is MaterialStateProperty<Size?>?.

And as Victor pointed out, we'll need a data-driven fix for this.


One thing that I'm wondering: is it possible that we'll introduce these new fields only to deprecate them in a few months?
We had plans to expand on our non-material theming system for more consistency across Material & Cupertino.

Maybe we should consider tabling this PR for now, and coming back to it once we decide whether CupertinoButton is going to have its own button style.

@StanleyCocos
Copy link
Contributor Author

Can we also add a dart fix to map current usage of minSize to minWidth and minHeight? This PR has an example of adding a dart fix.

Thank you for your guidance. I’d be happy to add this, but I’m not very familiar with implementing this feature. I might need some time to learn about it.

@StanleyCocos
Copy link
Contributor Author

StanleyCocos commented Jan 9, 2025

I remember Justin mentioning that the material library's ButtonStyle has a minimumSize property, and it looks like its type is MaterialStateProperty<Size?>?.

I’m not sure if I misunderstood your point. My understanding is that this doesn’t seem to conflict with my request. On the contrary, my request seems to align better with its standards. If I’m wrong, please let me know.

One thing that I'm wondering: is it possible that we'll introduce these new fields only to deprecate them in a few months?
We had plans to expand on our non-material theming system for more consistency across Material & Cupertino.

I believe standardizing the style should mean unifying the default style, but it shouldn’t prevent users from making modifications. I think users really need this property. I’m not sure what the future plans are, but I believe a button will certainly have these two properties.

Maybe we should consider tabling this PR for now, and coming back to it once we decide whether CupertinoButton is going to have its own button style.

I feel this request is very valuable. What should I do next?

@nate-thegrate
Copy link
Contributor

Apologies for my vague description earlier. It's possible that over the next few months, we'd decide on something like

CupertinoButton(
  style: CupertinoButtonStyle(
    minWidth: 20.0,
    minHeight: 10.0,
  ),
  // ...
)

If that ends up happening, I believe it'd be best to avoid introducing those fields to the widget constructor.

@StanleyCocos
Copy link
Contributor Author

I understand. Then I’ll wait for your work plan. Also, could I know where I can find the content of your ongoing discussions and plans?

@nate-thegrate
Copy link
Contributor

Sounds good, thanks!

Unfortunately I'm not aware of any ongoing discussions about it. The extent of my knowledge is that we were planning to start in early 2025… so hopefully soon!

Copy link
Contributor

@justinmc justinmc left a comment

Choose a reason for hiding this comment

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

@dkwingsmt Given your upcoming work on theming/styling, do you think it makes sense to make a change like this now or to wait for those changes first?

Comment on lines 79 to 85
this.minSize,
@Deprecated(
'Use minWidth and minHeight instead. '
'This feature was deprecated after v3.28.0-3.0.pre.',
)
double? minSize,
double? minWidth,
double? minHeight,
Copy link
Contributor

Choose a reason for hiding this comment

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

What if instead of adding minWidth and minHeight we add minimumSize of type Size? That way it matches ButtonStyle.minimumSize.

There is risk that this will end up deprecated due to a refactor of theming as @nate-thegrate mentioned, but maybe it's less likely this way? Since it matches ButtonStyle.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Your idea is fantastic! If this approach is acceptable, I’d be more than happy to adjust the functionality.

Copy link
Contributor

Choose a reason for hiding this comment

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

I can't think of any big plans to change this part of theming in the near future, unless @/nate-thegrate has such as plan.

Copy link
Contributor

Choose a reason for hiding this comment

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

Good to know, thank you Tong!

Copy link
Contributor

Choose a reason for hiding this comment

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

What's the status of this proposal? Seems like a no-brainer to keep the API surface compact.

Copy link
Contributor

Choose a reason for hiding this comment

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

Aside from the compact API surface, allowing a Size object could let us do something like

class WidgetStateSize extends Size implements WidgetStateProperty<Size?> {
  ...
}

Unfortunately, changing a parameter type while keeping the same name would be difficult. And an advantage of the current approach is that you could specify a minimum width without setting a minimum height if you wanted, whereas a Size object requires both to be set.

Maybe we could rename minSize to minimumSize and hope that it doesn't confuse anybody :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

API modifications indeed require great caution, and I also prefer adjusting the minimumSize parameter of the Size type.

I will make the necessary modifications.

Copy link
Contributor

Choose a reason for hiding this comment

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

How about the concern raised by @nate-thegrate where the user can no longer leave width or height empty without specifying both? Are there real world use cases there that are not possible with this approach? Could we take double.infinity in those cases, or is that not user-friendly enough?

Sorry for going back and forth on this point so much :) Just trying to make sure we make a good decision on the API here.

Copy link
Contributor

Choose a reason for hiding this comment

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

The back-and-forth is what I live for 😆

One option for maximum flexibility would be to accept a BoxConstraints object instead of a Size, but if a developer really wanted the fine-grain control they could just leave the minimumSize null and wrap the child with a ConstrainedBox.

I think a Size property would be great here!

Copy link
Contributor

Choose a reason for hiding this comment

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

Alright I will renew my LGTM and leave it up to @StanleyCocos.

@dkwingsmt
Copy link
Contributor

I'm ok with either adding minWidth/Height or minimumSize. I don't think a tentative theming refactor should block us on either of the choices, both because it's probably going to be a big project that's too far in the future to consider, and because it's probably going to deprecate a lot of things anyway.

nate-thegrate

This comment was marked as resolved.

@github-actions github-actions bot added the c: tech-debt Technical debt, code quality, testing, etc. label Jan 22, 2025
@StanleyCocos

This comment was marked as resolved.

engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Feb 5, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Feb 6, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Feb 6, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Feb 6, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Feb 6, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Feb 7, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Feb 7, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Feb 7, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Feb 8, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Feb 8, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Feb 9, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Feb 9, 2025
@StanleyCocos StanleyCocos deleted the feature/cupertion_button_min_size branch February 10, 2025 05:44
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Feb 10, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Feb 10, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Feb 10, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Feb 10, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Feb 10, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Feb 11, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Feb 11, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Feb 11, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Feb 11, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Feb 11, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request May 20, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request May 20, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request May 21, 2025
@Piinks Piinks mentioned this pull request Nov 6, 2025
9 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

c: tech-debt Technical debt, code quality, testing, etc. f: cupertino flutter/packages/flutter/cupertino repository framework flutter/packages/flutter repository. See also f: labels.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

CupertinoButton is missing minWidth and minHeight.

5 participants