I'm working on a project where I have 7 different GestureDetectors in a Stack widget. I'm trying to call onLongPress on all of them at once but after activating 5 of them, the others won't be called.
Is anyone familiar with any limitations in Flutter on the maximum number of simultaneously active GestureDetectors? Or might it be some limitations on the iOS and android devices. I can't find these constraints online.
Thanks!
For reproducible example, I added this Widget that lays out 7 GestureDetectors. The HapticFeedback is used to check whether the onLongPress was triggered or not. When I build this to my device, the max number of clicks I can register simultaneously is 5.
class GestureDetectors extends StatelessWidget {
@override
Widget build(BuildContext context) {
double screenWidth = MediaQuery.of(context).size.width;
double screenHeight = MediaQuery.of(context).size.height;
double width = screenWidth / 3;
double height = screenHeight / 3;
return Scaffold(
body: Wrap(
//spacing: 5,
//runSpacing: 5,
children: <Widget>[
GestureDetector(
onLongPress: () {
HapticFeedback.heavyImpact();
},
child: Container(
height: height,
width: width,
color: Colors.cyanAccent,
),
),
GestureDetector(
onLongPress: () {
HapticFeedback.heavyImpact();
},
child: Container(
height: height,
width: width,
color: Colors.deepPurple,
),
),
GestureDetector(
onLongPress: () {
HapticFeedback.heavyImpact();
},
child: Container(
height: height,
width: width,
color: Colors.orangeAccent,
),
),
GestureDetector(
onLongPress: () {
HapticFeedback.heavyImpact();
},
child: Container(
height: height,
width: width,
color: Colors.redAccent,
),
),
GestureDetector(
onLongPress: () {
HapticFeedback.heavyImpact();
},
child: Container(
height: height,
width: width,
color: Colors.blueAccent,
),
),
GestureDetector(
onLongPress: () {
HapticFeedback.heavyImpact();
},
child: Container(
height: height,
width: width,
color: Colors.pinkAccent,
),
),
GestureDetector(
onLongPress: () {
HapticFeedback.heavyImpact();
},
child: Container(
height: height,
width: screenWidth,
color: Colors.lightGreenAccent,
),
),
],
));
}
}
CodePudding user response:
There might be a issue of this :
IgnorePointer is a built-in widget in flutter which is similar to the AbsorbPointer widget, they both prevent their children's widget from pointer-events which are taping, clicking, dragging, scrolling, and hover.
CodePudding user response:
It seems that iPhones supports a maximum 5 simultaneous touches, and cancels them all on the 6th touch.
iPad models (through Air 2), however, support 11 simultaneous touches, and do nothing on a 12th touch.
