Skip to content

Allows customization of the mouse cursor via ThemeData for InkWell/InkResponse - #182652

Closed
pagetronic wants to merge 8 commits into
flutter:masterfrom
pagetronic:master
Closed

pagetronic wants to merge 8 commits into
flutter:masterfrom
pagetronic:master

Conversation

@pagetronic

@pagetronic pagetronic commented Feb 20, 2026 •

Copy link
Copy Markdown

The recent change in PR #171796, which changes the default mouse cursor for buttons to a basic arrow, explicitly cites its reason as being "as per updated Android guidance."
However, this platform-specific guidance has been implemented globally, affecting all platforms (except web and because Material specs..), including desktop.

On desktop platforms, a pointer/click cursor is the standard and universally expected user experience for interactive elements.

This has resulted in a significant UX regression for all non-Android platforms. The core issue is that a guideline intended for Android's touch-first interface has been applied to pointer-based platforms where the visual feedback of a cursor change is essential for usability.

Fixe this issue #182466

These changes, which preserve previous modifications while offering the possibility of modifying them via ThemeData.

ThemeData(
      textButtonTheme: TextButtonThemeData(
        style: (textButtonTheme.style ?? ButtonStyle()).copyWith(
          mouseCursor: defaultTargetPlatform != TargetPlatform.android ? WidgetStateMouseCursor.clickable : WidgetStateMouseCursor.adaptiveClickable,
        ),
      ),
    )
extension on ThemeData {
  ThemeData? makeMouseClickable() {
    WidgetStateMouseCursor clickable = defaultTargetPlatform != TargetPlatform.android ? WidgetStateMouseCursor.clickable : WidgetStateMouseCursor.adaptiveClickable;
    return copyWith(
      elevatedButtonTheme: ElevatedButtonThemeData(style: (elevatedButtonTheme.style ?? ButtonStyle()).copyWith(mouseCursor: clickable)),
      filledButtonTheme: FilledButtonThemeData(style: (filledButtonTheme.style ?? ButtonStyle()).copyWith(mouseCursor: clickable)),
      outlinedButtonTheme: OutlinedButtonThemeData(style: (outlinedButtonTheme.style ?? ButtonStyle()).copyWith(mouseCursor: clickable)),
      floatingActionButtonTheme: floatingActionButtonTheme.copyWith(mouseCursor: clickable),
      iconButtonTheme: IconButtonThemeData(style: (iconButtonTheme.style ?? ButtonStyle()).copyWith(mouseCursor: clickable)),
      menuButtonTheme: MenuButtonThemeData(style: (menuButtonTheme.style ?? ButtonStyle()).copyWith(mouseCursor: clickable)),
      menuTheme: MenuThemeData(submenuIcon: menuTheme.submenuIcon, style: (menuTheme.style ?? MenuStyle()).copyWith(mouseCursor: clickable)),
      checkboxTheme: checkboxTheme.copyWith(mouseCursor: clickable),
      popupMenuTheme: popupMenuTheme.copyWith(mouseCursor: clickable),
      segmentedButtonTheme: segmentedButtonTheme.copyWith(style: (segmentedButtonTheme.style ?? ButtonStyle()).copyWith(mouseCursor: clickable)),
      textButtonTheme: TextButtonThemeData(style: (textButtonTheme.style ?? ButtonStyle()).copyWith(mouseCursor: clickable)),
      dataTableTheme: dataTableTheme.copyWith(dataRowCursor: clickable),
      dropdownMenuTheme: dropdownMenuTheme.copyWith(menuStyle: (dropdownMenuTheme.menuStyle ?? MenuStyle()).copyWith(mouseCursor: clickable)),
    );
  }
}

@github-actions github-actions Bot added framework flutter/packages/flutter repository. See also f: labels. p: material_ui material_ui package in flutter/packages labels Feb 20, 2026
@pagetronic
pagetronic marked this pull request as ready for review February 20, 2026 07:48

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review

The pull request introduces customization of the mouse cursor for InkWell and InkResponse via ThemeData. While this addresses a valid UX concern on desktop platforms, the current implementation has several technical and architectural issues. Specifically, the theme property is given precedence over the widget's local property, and the use of an unsafe cast limits the types of WidgetStateProperty that can be used. Furthermore, tying the generic InkWell primitive to textButtonTheme creates an inappropriate dependency across the Material library.

Comment thread packages/flutter/lib/src/material/ink_well.dart Outdated
Comment thread packages/flutter/lib/src/material/ink_well.dart
@flutter-dashboard

Copy link
Copy Markdown

It looks like this pull request may not have tests. Please make sure to add tests or get an explicit test exemption before merging.

If you are not sure if you need tests, consider this rule of thumb: the purpose of a test is to make sure someone doesn't accidentally revert the fix. Ask yourself, is there anything in your PR that you feel it is important we not accidentally revert back to how it was before your fix?

Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing. If you believe this PR qualifies for a test exemption, contact "@test-exemption-reviewer" in the #hackers channel in Discord (don't just cc them here, they won't see it!). The test exemption team is a small volunteer group, so all reviewers should feel empowered to ask for tests, without delegating that responsibility entirely to the test exemption group.

@dkwingsmt
dkwingsmt self-requested a review February 25, 2026 19:53
@flutter-dashboard

Copy link
Copy Markdown

This pull request executed golden file tests, but it has not been updated in a while (20+ days). Test results from Gold expire after as many days, so this pull request will need to be updated with a fresh commit in order to get results from Gold.

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.

@dkwingsmt

Copy link
Copy Markdown
Contributor

Thanks for you contribution! However, I'd like us to first agree on the API design by discussing under #182466 before moving on to the actual implementation to avoid wasting effort on the PR. (Also, PRs like this should be accompanied by unit tests.)

Also, sorry for late review!

@dkwingsmt

dkwingsmt commented Apr 8, 2026 •

Copy link
Copy Markdown
Contributor

I'm going to close this PR since I do not agree with the design in this PR, as I've commented under the original issue. Feel free to post another PR following that design or join the discussion there if you have other ideas. Thank you for the contribution!

@dkwingsmt dkwingsmt closed this Apr 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

framework flutter/packages/flutter repository. See also f: labels. p: material_ui material_ui package in flutter/packages

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants