Reputation: 24087
I have a Stack
widget that contains two Image
widgets, one image overlaying the other. One image has top set to 10 so it sits 10 pixels higher on the screen. Unfortunately the 10.0px gets cut off at the bottom of the screen. If I set an overflow.visible
then I can see it.
I wrap the stack with a GestureDetector
the 10.0px overflow is not inside the GestureDetector
so when a user clicks on the bottom of the image, nothing happens. The images will be different sizes so I can't set a definite height.
Is there a way to increase the size of the GestureDector
to the size of its children?
return new GestureDetector(
onTapDown: (x) => print('onTapDown'),
child: new Stack(
overflow: Overflow.visible,
children: [
new Positioned(
child: shadowImage,
top: 10.0,
),
new Positioned(
child: initialImage,
),
],
),
);
Upvotes: 2
Views: 1414
Reputation: 276997
Can (should?) Stack expand its size to its positioned children?
No. But if you want the following, then your child should not be positionned.
Stack
, if it has one, will size itself around the first non-positionned child.
So you could transform your shadowImage
to
children: [
new Padding(
padding: const EdgeInsets.only(top: 10.0),
child: shadowImage
),
new Positioned(
child: initialImage,
),
],
Upvotes: 7