flutter-defer-pointer icon indicating copy to clipboard operation
flutter-defer-pointer copied to clipboard

is it possible to use this plugin if you set negative transforms?

Open NickKoroloff opened this issue 3 years ago • 2 comments

Container(
      transform: Matrix4.translationValues(-150, -150, 0.0),
)

NickKoroloff avatar Feb 08 '22 16:02 NickKoroloff

Have you tried?

esDotDev avatar Mar 22 '22 02:03 esDotDev

I just tried with a translated and rotated TextButton and unfortunately it doesn't seem to work:

  @override
  Widget build(BuildContext context) {
    return DeferredPointerHandler(
      child: Stack(
        children: [
          _buildButton(math64.Vector3(20, 20, 0), rotateY: pi/2),
        ],
      ),
    );
  }

  Transform _buildButton(math64.Vector3 translate, {double rotateX = 0.0, double rotateY = 0.0}) {
    return Transform(
      transform: math64.Matrix4.identity()
        ..rotateX(rotateX)
        ..rotateY(rotateY)
        ..translate(translate),
      alignment: Alignment.topLeft,
      child: DeferPointer(
        child: TextButton(
          onPressed: () => print('clicked'),
          child: Text('Click', style: TextStyle(color: Colors.white),),
        ),
      ),
    );
  }

Is this package supposed to work with transformed items at all, and if yes, how does the code have to be adjusted? If not, do you guys have an idea how the click area for a widget (or defined with GestureDetection as parent) can be transformed as well in order that click events still work even after the transformation?

EDIT: I have to correct myself, it actually works fine, i just had to insert DeferredPointerHandler some more levels higher in the hierarchy.

rivella50 avatar Jun 30 '23 12:06 rivella50