Closed ricardogobbo closed 4 years ago
This happens because the FlightBarcode
is Wrapped inside a Gesture detector here.
You can refer here to find how to that behavior.
That's an unexpected behavior.
Look at this Widget. When I tap on red container, onTap is fired. When I press the button, onPressed is triggered.
class MyHomePage extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(title: Text("GestureDetector Test")),
body: Column(
children: <Widget>[
GestureDetector(
onTap: () => print("gestureDetector onTap"),
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: <Widget>[
Container(
color: Colors.red,
height: 200,
child: Text("Gesture"),
),
FlatButton(
child: Text("button"),
onPressed: () => print("button onPressed"),
)
],
),
)
],
),
);
}
}
In the Flutter documentation here it is mentioned that in Gesture Arena only one of the Gesture is declared as victorious. This might differ from one case to another case. Hence it requires custom GestureDetectors.
Gesture arena didn't recognize button onPressed gesture.
Gesture arena 48 ❙ ★ Opening new gesture arena.
// GestureDetector's onTap
Gesture arena 48 ❙ Adding: TapGestureRecognizer#6cdd6(debugOwner: GestureDetector, state: ready, button: 1)
// ListView scroll
Gesture arena 48 ❙ Adding: VerticalDragGestureRecognizer#675e5(start behavior: start)
Gesture arena 48 ❙ Closing with 2 members.
Gesture arena 48 ❙ Rejecting: VerticalDragGestureRecognizer#675e5(start behavior: start)
Gesture arena 48 ❙ Sweeping with 1 member.
Gesture arena 48 ❙ Winner: TapGestureRecognizer#6cdd6(debugOwner: GestureDetector, state: ready, finalPosition: Offset(129.4, 493.4), finalLocalPosition: Offset(129.4, 380.3), button: 1, sent tap down)
We've refactored the example to allow for embedded buttons :)
Steps to reproduce:
flight_barcode.dart
and add a FlatButton like follows:The onTap function doesnt trigger. The card keeps folding.