-
Notifications
You must be signed in to change notification settings - Fork 28k
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
Interactive size const #36964
Interactive size const #36964
Conversation
I ended up having to create a widgets/constants.dart file and duplicating the material constant there to avoid circular dependencies. Is there a better place to put these constants? Or should I rename the widgets constant to "kMinInteractiveDimensionGeneric" or something like that? |
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.
NICE, LGTM.
/// See also: | ||
/// | ||
/// * [kMinInteractiveDimensionCupertino] | ||
const double kMinInteractiveDimension = 48.0; |
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.
This is covered in the "Touch and pointer size" section of the material spec: https://material.io/design/usability/accessibility.html
Probably should provide a link to it.
/// size](https://material.io/guidelines/layout/metrics-keylines.html#metrics-keylines-touch-target-size) | ||
/// The hit region of an icon button will, if possible, be at least | ||
/// kMinInteractiveDimension pixels in size, regardless of the actual | ||
/// [iconSize], to satisfy the [touch target size](https://material.io/guidelines/layout/metrics-keylines.html#metrics-keylines-touch-target-size) |
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.
Might not be the best spec link; see earlier comment
/// The minimum size that a widget should be in order to be easily interacted | ||
/// with by the user. | ||
@visibleForTesting | ||
const double kMinInteractiveSize = 48.0; |
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.
Unfortunately this change makes the PR backwards incompatible. It's a pretty minor one as these things go; but tests may break. We should follow the breaking change protocol for this PR.
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.
True. I'll send out that email in a few minutes.
Breaking Change Announcement Draft[Breaking Change] Removing kMinInteractiveSize in text_selection.dart I'm proposing to remove the constant kMinInteractiveSize from text_selection.dart. This constant was annotated with In many places around the framework, we had duplicated hardcoded values for the minimum touch target size (48 pixels for Material and 44 for Cupertino). The PR consolidates all of those duplicate values into a few shared constants to avoid code duplication. Anyone who may have been using kMinInteractiveSize should replace it with kMinInteractiveDimension in widgets/constants.dart, which is added in the referenced PR. Please let me know if you have any trouble migrating and need some help! I'm available by email and chat. If anyone objects to this change or would like to discuss further, please comment in the linked PR. Thanks, Justin |
Description
Lots of places in the codebase have a hardcoded value of 48x48 pixels (material) or 44x44 pixels (cupertino) in order to size hit targets in a way that's easily interactive. This PR pulls these two values out as constants and reuses them in all of the places where it was previously hardcoded.
Related Issues
Closes #36713
Tests
Updated tests that were using an old duplicated constant.