Am I missing something? The documentation says that events bubble up from the innermost child to the ancestors, but below code will not print "dragged" to the console. It does print "tapped" though. Applying NeverScrollablePhyiscs to the ListView does work, but i want to listen on the event on both levels. Applying HitTestBehavior.translucent to the GestureDetector doesn't change anything.
import "package:flutter/material.dart";
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
home: MyHomePage(),
);
}
}
class MyHomePage extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
body: GestureDetector(
onVerticalDragUpdate: (DragUpdateDetails details) {
print("dragged");
},
onTap: () {
print("tapped");
},
child: ListView.builder(
itemBuilder: (context, index) {
return Container(
padding: EdgeInsets.all(20.0),
child: Text(
"The GestureDetector above me does not react to drag events. Maybe my parent is at fault?"
)
);
},
)
)
);
}
}
You can listen for raw pointer events using Listener
return Scaffold(
body: Listener(onPointerMove: (opm) {
print("onPointerMove .. ${opm.position}");
}, child: ListView.builder(
itemBuilder: (context, index) {
return Container(
padding: EdgeInsets.all(20.0),
child: Text(
"The GestureDetector above me does not react to drag events. Maybe my parent is at fault?"));
},
)));
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With