Repository navigation
ListWheelScrollView children do not respond on gesture (onTap) events #38803
Copy link
Copy link
Closed
Labels
P3Issues that are less important to the Flutter projectIssues that are less important to the Flutter projectcustomer: crowdAffects or could affect many people, though not necessarily a specific customer.Affects or could affect many people, though not necessarily a specific customer.f: gesturesflutter/packages/flutter/gestures repository.flutter/packages/flutter/gestures repository.f: scrollingViewports, list views, slivers, etc.Viewports, list views, slivers, etc.found in release: 1.18Occurs in 1.18Occurs in 1.18found in release: 1.24Found to occur in 1.24Found to occur in 1.24frameworkflutter/packages/flutter repository. See also f: labels.flutter/packages/flutter repository. See also f: labels.has reproducible stepsThe issue has been confirmed reproducible and is ready to work onThe issue has been confirmed reproducible and is ready to work on
Description
Steps to Reproduce
Hi! Here is my widget that uses ListWheelScrollView with FixedExtentScrollController:
import 'package:flutter/material.dart';
class LetterWheel extends StatefulWidget {
const LetterWheel({Key key}) : super(key: key);
@override
_LetterWheelState createState() => _LetterWheelState();
}
class _LetterWheelState extends State<LetterWheel> {
FixedExtentScrollController scrollController;
@override
void initState() {
scrollController = FixedExtentScrollController();
super.initState();
}
@override
void dispose() {
scrollController.dispose();
super.dispose();
}
@override
Widget build(BuildContext context) {
return ListWheelScrollView(
controller: scrollController,
physics: const FixedExtentScrollPhysics(),
itemExtent: 110,
children: ['A', 'B', 'C', 'D', 'E', 'F', 'G']
.map(
(letter) => Container(
margin: const EdgeInsets.all(10),
height: 90,
color: Colors.yellow,
child: GestureDetector(
onTap: () => print('Letter "$letter" is pressed.'),
child: Center(
child: Text(
letter,
style: const TextStyle(fontSize: 20, fontWeight: FontWeight.bold),
),
),
),
),
)
.toList(),
);
}
}Expected result: When the list item is tapped the message is printed to the console.
Actual result: When the list item is tapped nothing happens.
Here is my flutter doctor -v output:
[✓] Flutter (Channel stable, v1.7.8+hotfix.3, on Mac OS X 10.14.5 18F203, locale en-UA)
• Flutter version 1.7.8+hotfix.3 at /Users/mkofan/Software/flutter
• Framework revision b712a172f9 (6 weeks ago), 2019-07-09 13:14:38 -0700
• Engine revision 54ad777fd2
• Dart version 2.4.0
[✓] Android toolchain - develop for Android devices (Android SDK version 29.0.1)
• Android SDK at /Users/mkofan/Library/Android/sdk
• Android NDK location not configured (optional; useful for native profiling support)
• Platform android-29, build-tools 29.0.1
• Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
• Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1343-b01)
• All Android licenses accepted.
[✓] Xcode - develop for iOS and macOS (Xcode 10.2.1)
• Xcode at /Applications/Xcode.app/Contents/Developer
• Xcode 10.2.1, Build version 10E1001
• CocoaPods version 1.7.4
[✓] iOS tools - develop for iOS devices
• ios-deploy 1.9.4
[!] Android Studio (version 3.4)
• Android Studio at /Applications/Android Studio.app/Contents
• Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1343-b01)
[✓] VS Code (version 1.37.1)
• VS Code at /Applications/Visual Studio Code.app/Contents
• Flutter extension version 3.3.0
[✓] Connected device (1 available)
• Android SDK built for x86 64 • emulator-5554 • android-x64 • Android 9 (API 28) (emulator)
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
P3Issues that are less important to the Flutter projectIssues that are less important to the Flutter projectcustomer: crowdAffects or could affect many people, though not necessarily a specific customer.Affects or could affect many people, though not necessarily a specific customer.f: gesturesflutter/packages/flutter/gestures repository.flutter/packages/flutter/gestures repository.f: scrollingViewports, list views, slivers, etc.Viewports, list views, slivers, etc.found in release: 1.18Occurs in 1.18Occurs in 1.18found in release: 1.24Found to occur in 1.24Found to occur in 1.24frameworkflutter/packages/flutter repository. See also f: labels.flutter/packages/flutter repository. See also f: labels.has reproducible stepsThe issue has been confirmed reproducible and is ready to work onThe issue has been confirmed reproducible and is ready to work on
Activity
kofan commentedon Aug 20, 2019
Here is a similar unresolved issue on Stackoverflow.
spiderion commentedon Sep 10, 2019
spiderion commentedon Sep 11, 2019
@kofan did you find any solution?
kofan commentedon Nov 23, 2019
Unfortunately, no. I didn't find a solution. I've abandoned the initial design that was based on
ListScrollViewand fallen back to a regularListView😔TimG38 commentedon Jan 17, 2020
A couple reports from:
And my own testing, example snippet:
That ListTile’s
onTapdoesn’t respond, no print is seen.Even if I wrap a child with
GestureDetector, such as:The GestureDetector’s
onTapalso doesn’t respond.I’ve also tried a
Button, same thing with theonPressed.But if I replace ListWheelScrollView with
ListView, then all is working as expected.It seems the only ways to interact with this is through
onSelectedItemChangedor the controller’sselectedItem?charlessfriend commentedon Feb 4, 2020
TimG38 commentedon Feb 5, 2020
We're looking for tap/touch response on the individual children of the
ListWheelScrollView, not on the list itself.charlessfriend commentedon Feb 6, 2020
As a workaround, you can use that same code and just calculate where the tap occurred. Based on the size of your ListWheelScrollView, you can figure out if the tap is within the child's rect. And you should know which child based on the onSelectedItemChanged. You can also use GlobalKey to get the context of the selected child and get the rect of that child and it's descendants. You can then use callbacks to call child methonds.
Moatasem1994 commentedon Feb 24, 2020
rostopira commentedon Feb 24, 2020
sgehrman commentedon Mar 27, 2020
Stuazt commentedon Apr 13, 2020
50 remaining items
Cilestal commentedon Jan 19, 2021
For ListWheelScrollView with a fixed height for child, you can use https://pub.dev/packages/clickable_list_wheel_view
mjlorenzo commentedon Jan 27, 2021
Google,
I understand ListWheelScrollView children not receiving input gestures is a fairly reasonable design decision. On the other hand, not making this crystal clear in your documentation is obnoxious. It stands to reason items in this list widget would behave identically to a standard list views unless otherwise specified. I wasted three hours today trying to figure out where I was going wrong because this behavior is completely ignored by the official API reference. I may waste more changing course completely. One sentence on the class reference page would do wonders.
medst commentedon Jul 9, 2021
AzadCoder commentedon Oct 25, 2021
Cilestal commentedon Nov 6, 2021
https://pub.dev/packages/clickable_list_wheel_view
banzhuan-jing commentedon Jan 6, 2023
Terranic commentedon Jan 14, 2023
LkyYuen commentedon Feb 2, 2023
anypwx commentedon Feb 23, 2023
nt4f04uNd commentedon Feb 23, 2023
Please read https://github.com/flutter/flutter/wiki/Issue-hygiene#do-not-add-me-too-or-same-or-is-there-an-update-comments-to-bugs and https://github.com/flutter/flutter/blob/master/CODE_OF_CONDUCT.md before commenting here
anypwx commentedon Feb 23, 2023
github-actions commentedon Apr 13, 2023
This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of
flutter doctor -vand a minimal reproduction of the issue.