Skip to content

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

Open
pagetronic wants to merge 7 commits intoflutter:masterfrom
pagetronic:master
Open

Allows customization of the mouse cursor via ThemeData for InkWell/InkResponse#182652
pagetronic wants to merge 7 commits intoflutter:masterfrom
pagetronic:master

Conversation

@pagetronic
Copy link

@pagetronic pagetronic commented Feb 20, 2026

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. f: material design flutter/packages/flutter/material repository. labels Feb 20, 2026
@pagetronic pagetronic marked this pull request as ready for review February 20, 2026 07:48
Copy link
Contributor

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

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.

@flutter-dashboard
Copy link

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
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.

1 participant