How can a positioned Widget feel taps outside of its parent Stack area?

Posted by Andre Scott | Updated on

In this example, I will share how can a positioned Widget feel taps outside of its parent Stack area? This behavior occurs because the stack checks whether the pointer is inside its bounds before checking whether a child got hit:

Class: RenderBox (which RenderStack extends)

My workaround is deleting the

check. Unfortunately, this is not possible without copying code from the framework.

Here is what I did:

1. Copied the Stack class and named it Stack2
2. Copied RenderStack and named it RenderStack2
3. Made Stack2 reference RenderStack2
4. Added the hitTest method from above without the _size.contains check
5. Copied Positioned and named it Positioned2 and made it reference Stack2 as its generic parameter
6. Used Stack2 and Positioned2 in my code

This solution is by no means optimal, but it achieves the desired behavior.


If you like this question & answer and want to contribute, then write your question & answer and email to freewebmentor[@]gmail.com. Your question and answer will appear on FreeWebMentor.com and help other developers.

Related Questions & Answers