RomanBase / hand_signature

A Flutter plugin providing signature pad for drawing smooth signatures.
https://pub.dev/packages/hand_signature
MIT License
108 stars 25 forks source link

HandSignature inside ListView #43

Closed aarajput closed 10 months ago

aarajput commented 11 months ago

If you please HandSignature widget inside ListVew and user tried to make a signature, list also move up and down with it.

RomanBase commented 11 months ago

Hey, by design it's not possible to use 'drawing' Widget inside any ScrollView. But you can solve this issue with little workaround - please check scroll_test in example.

Basically you need to prevent ScrollView from receiving gesture events - there is multiple ways how to achieve this (Focus, Listener, IgnorePointer, GestureDetector etc) based on your needs. In example you can find disabling scroll physics with NeverScrollableScrollPhysics on pointer down event.

Please check also similar issues: #38, #2

aarajput commented 6 months ago

Here is how i fixed this issue. I just wrapped HandSignature widget with GestureDetector widget and passed onHorizontalDragUpdate and onVerticalDragUpdate with empty function.

Example:

GestureDetector(
              onHorizontalDragUpdate: (_) {},
              onVerticalDragUpdate: (_) {},
              child: HandSignature(
                control: controller,
                color: Colors.black,
          ),
)

@RomanBase , i think you sould add this login in _example/lib/scrolltest.dart

RomanBase commented 6 months ago

Hey, as mentioned above there is multiple solutions and every app will have other challenges to achieve correct behavior. I think you solution (not tested) will not work inside PageView, because you override 'drag' events. So in example is most general solution (maybe not correct for every Scrollable) that works as a 'hint' how to achieve something like this.

For example in our production code we mostly uses Overlay so 'Drawing Pad' is above Scrollable.