Skip to content

Conversation

victorsanni
Copy link
Contributor

@victorsanni victorsanni commented Jul 21, 2025

@github-actions github-actions bot added framework flutter/packages/flutter repository. See also f: labels. f: cupertino flutter/packages/flutter/cupertino repository labels Jul 21, 2025
@github-actions github-actions bot added the f: material design flutter/packages/flutter/material repository. label Jul 22, 2025
@flutter-dashboard
Copy link

Golden file changes have been found for this pull request. Click here to view and triage (e.g. because this is an intentional change).

If you are still iterating on this change and are not ready to resolve the images on the Flutter Gold dashboard, consider marking this PR as a draft pull request above. You will still be able to view image results on the dashboard, commenting will be silenced, and the check will not try to resolve itself until marked ready for review.

For more guidance, visit Writing a golden file test for package:flutter.

Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing.

Changes reported for pull request #172502 at sha fd3da40

@flutter-dashboard flutter-dashboard bot added the will affect goldens Changes to golden files label Jul 22, 2025
@victorsanni
Copy link
Contributor Author

Scuba changes are pretty bad. Maybe we can add it as an optional parameter and have it stick to its current default.

@victorsanni victorsanni marked this pull request as draft July 22, 2025 20:05
@victorsanni victorsanni removed the request for review from MitchellGoodwin July 22, 2025 20:05
@flutter-dashboard
Copy link

This pull request has been changed to a draft. The currently pending flutter-gold status will not be able to resolve until a new commit is pushed or the change is marked ready for review again.

For more guidance, visit Writing a golden file test for package:flutter.

Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing.

@github-actions github-actions bot removed the f: material design flutter/packages/flutter/material repository. label Jul 22, 2025
@victorsanni victorsanni changed the title Adjust CupertinoCheckbox padding from 44px to 18px Add CupertinoCheckbox.tapTargetSize Jul 22, 2025
@victorsanni
Copy link
Contributor Author

This is tricky because if we expose the tapTargetSize, there is weird behavior if they supply a size <18px:

Screenshot 2025-09-03 at 11 30 10 AM

The solutions I think could work here are:

  • Hard break everyone to move to 18px since checkboxes aren't recommended on mobile anyways
  • add the 18px checkbox as a new constructor (CupertinoCheckbox.small/CupertinoCheckbox.large or CupertinoCheckbox.mobile/CupertinoCheckbox.desktop)
  • add the tapTargetSize property and assert a minimum size of 18x18 px

Which of these should we proceed with @MitchellGoodwin?

@MitchellGoodwin
Copy link
Contributor

My vote is for

add the tapTargetSize property and assert a minimum size of 18x18 px

Besides visual appearance changes, tap targets are in the realm of accessibility so I'm a little nervous to make breaking changes when it comes to that. Also, rather than 18x18, it might make sense to make the minimum 14x14. 18 is the width of the radio, 14 is the width of the checkbox. I don't know if we need to enforce having a tap target bigger than the checkbox.

Right now the width of the checkbox is set by a static value. I think the min TapTargetSize and the width should point to the same value.

I think we can merge this in and then consider a breaking change after. I think we might want to consider having tapTargetSize default to it's current value on mobile, and to a lower default on all other platforms. That makes the most sense to me, but would be breaking on desktop and web.

@victorsanni
Copy link
Contributor Author

I think we might want to consider having tapTargetSize default to it's current value on mobile, and to a lower default on all other platforms.

That's an option I didn't consider. And might help with the google tests as well. Plus, it means we don't have to increase the API surface.

@MitchellGoodwin
Copy link
Contributor

Another thing to consider is that it's common to adjust the size of the checkbox with Transform.scale, so whatever we do we need to make sure it works as expected with that.

@victorsanni victorsanni marked this pull request as ready for review September 3, 2025 19:27
@victorsanni victorsanni changed the title Add CupertinoCheckbox.tapTargetSize Adjust default CupertinoCheckbox size on desktop Sep 3, 2025
TargetPlatform.fuchsia => const Size.square(kMinInteractiveDimensionCupertino),
TargetPlatform.macOS ||
TargetPlatform.linux ||
TargetPlatform.windows => const Size.square(CupertinoCheckbox.width),
Copy link
Contributor

Choose a reason for hiding this comment

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

CupertinoCheckbox.width is 14 while the size tested in the original issue is 18, which looks pretty good. Will 14 be too small?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No, I think the issue has 18px because of the default macOS padding. But it's probably best to leave any additional padding customizations to the user.

Copy link
Contributor

@dkwingsmt dkwingsmt left a comment

Choose a reason for hiding this comment

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

I think a better way is to expose a size property that applies the platform-dependent default size in this PR. What do you think?

@victorsanni
Copy link
Contributor Author

I think a better way is to expose a size property that applies the platform-dependent default size in this PR. What do you think?

It gets weird because the size here doesn't actually affect the size of the checkbox, just the area that, when tapped, toggles the checkbox.

@dkwingsmt
Copy link
Contributor

I see that Material has a MaterialTapTargetSize that does a similar job. It's actually an enum, which does exactly what your current switch statement does. That being said, I think the enum is a bad choice (it was added in 2018 anyway) but we can call this new property tapTargetSize and make it a Size.

Copy link
Contributor

@dkwingsmt dkwingsmt left a comment

Choose a reason for hiding this comment

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

LGTM, thank you

Copy link
Contributor

@MitchellGoodwin MitchellGoodwin left a comment

Choose a reason for hiding this comment

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

LGTM with one nit on the documentation

@@ -66,6 +66,9 @@ const List<double> _kDisabledDarkGradientOpacities = <double>[0.08, 0.14];
/// ([CupertinoSwitch] in Flutter) instead, or to find a creative custom
/// solution.
///
/// The checkbox has a default size of 14-by-14 pixels on desktop devices and
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: I think this should clarify that the size difference is only the tap target area and layout padding. The actual visual checkbox itself is 14-by-14 on all platforms with this change.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
f: cupertino flutter/packages/flutter/cupertino repository framework flutter/packages/flutter repository. See also f: labels. will affect goldens Changes to golden files
Projects
None yet
Development

Successfully merging this pull request may close these issues.

CupertinoCheckbox padding on MacOS is excessive, is applying iOS standards
3 participants