Skip to content
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

Added new parameter disabledChildrenInteraction on CarouselView to allow developer to control which part is clickable #155214

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

SuicaLondon
Copy link
Contributor

@SuicaLondon SuicaLondon commented Sep 15, 2024

Add disabledChildrenInteraction parameter to CarouselView widget

This PR addresses issues #155199 and #154701 by adding a new parameter to the CarouselView widget that allows developers to control which parts of the carousel are clickable. Currently, an InkWell covers the entire carousel, preventing child widgets from being clickable even when children widget have their clickable widgets.

The new disabledChildrenInteraction parameter allows developers to disable this default behavior of InkWell without breaking any existing code. If disabledChildrenInteraction is false, the onTap of the CarouselView will be disabled. And developer can define their own click behavior likes animation ,the clickable widget and so on.

I have added some new test cases and passed all of them

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

If you need help, consider asking for advice on the #hackers-new channel on [Discord].

…action

- Modified the InkWell in _buildCarouselItem method to remove tap functionality
  when widget.onTap is null
- This change allows child widgets (e.g., buttons) to maintain their own tap
  behavior without interference from the CarouselView
- Improves usability when CarouselView contains interactive elements
- Ensures no unintended splash effects occur on the carousel item when
  widget.onTap is not provided

This update enhances the flexibility of CarouselView, making it more
compatible with various types of child widgets while maintaining its
core functionality.
@github-actions github-actions bot added framework flutter/packages/flutter repository. See also f: labels. f: material design flutter/packages/flutter/material repository. labels Sep 15, 2024
@mhmzdev
Copy link

mhmzdev commented Sep 15, 2024

Mentioning a simple solution just in case #155218

@SuicaLondon
Copy link
Contributor Author

Mentioning a simple solution just in case #155218

You can checked my first commit, I was using onTap at first, but it will break some existing test cases. It may be a breaking change for some existing code. Also, using onTap as guard will cause another issue that it will lose the extendibility in the future if we want to do something like hierarchy gesture detection. For that reason, it will be better to have another parameter to control its behavior.

@mhmzdev
Copy link

mhmzdev commented Sep 16, 2024

@SuicaLondon I think you're right. Should I close my PR?

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.

2 participants