4Q-s-r-o / signature

Flutter plugin that creates a canvas for writing down a signature
MIT License
255 stars 85 forks source link

Cannot continue drawing when the signature is interrupted #40

Closed ChannelYu closed 3 years ago

ChannelYu commented 3 years ago

https://user-images.githubusercontent.com/7424823/117410258-c4d71900-af44-11eb-84bd-7fdb940b3849.mov

The user might accidentally touch the status bar like in the video, and the Listener object does not handle the cancellation callback, so the user can not continue drawing while this is happening.

Add Listener.onPointerCancel may solves this problem :

class SignatureState extends State<Signature> {

  @override
  Widget build(BuildContext context) {
    ...
    Listener(
      ...
      onPointerCancel: (PointerCancelEvent event) {
           if (activePointerId == event.pointer) {
              _addPoint(event, PointType.tap);
              widget.controller.onDrawEnd?.call();
              activePointerId = null;
            }
      },
    );
  }
}

Here are the results:

https://user-images.githubusercontent.com/7424823/117412645-97d83580-af47-11eb-938f-7ca3b968c785.mov

MartinHlavna commented 3 years ago

Thanks for the fix!

MartinHlavna commented 3 years ago

Version 4.1.1 is published