I am trying to implement a re-sizable widget with handles at the corners. The corner handles will be overflow the Stack
by half of its width/height.
Issue: the outer part of handle does not report gesture events while the inner part is working fine.
It is intended or I am doing some thing wrong. If it is intended behavior then what to do next.
sample code
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: Colors.green,
body: Transform.translate(
offset: boxOffset,
child: Stack(
overflow: Overflow.visible,
fit: StackFit.expand,
children: <Widget>[
Container(
width: 100.0,
height: 100.0,
color: Colors.red,
),
Positioned(
left: 100.0 - 20.0,
top: 100.0 - 20.0,
child: GestureDetector(
onTap: () {print("tapped");},
child: Container(
width: 80.0,
height: 80.0,
color: Colors.blue,
),
),
)
],
),
)
);
}
deferToChild → const HitTestBehavior. Targets that defer to their children receive events within their bounds only if one of their children is hit by the hit test.
A stack overflow is a type of buffer overflow error that occurs when a computer program tries to use more memory space in the call stack than has been allocated to that stack.
This is the desired behavior. If widgets could catch pointer events outside of their boundaries; it would be easy to fall into a situation where it's impossible to determine which widget is targeted.
In short, don't use overflow. Refactor your layout to make sure it's well contained inside the bounds of its parent.
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