Closed beamAkshay closed 1 year ago
Unfortunately we can't stop listening for events. You can kinda get away with implementing onLongPressEnd also, but if user starts to draw immediately without lifting finger it would also clear the points. But maybe you can work from there
GestureDetector(
child: Signature(
key: const Key('signature'),
controller: _controller,
height: 300,
backgroundColor: Colors.grey[300]!,
),
onLongPress: () {
setState(() {
_controller.clear();
});
},
onLongPressEnd: (details) {
setState(() {
_controller.clear();
});
},
),
If PR #89 gets merged it could also come in handy for you since you can disable canvas in onLongPress and reenable it in onLongPressEnd
5.4.0
with PR #89 has been published. Now you can do
GestureDetector(
onLongPress: () {
setState(() {
_controller.disabled = true;
_controller.clear();
});
},
onLongPressUp: (){
setState(() {
_controller.disabled = false;
});
},
child: Signature(
key: const Key('signature'),
controller: _controller,
height: 300,
backgroundColor: Colors.grey[300]!,
),
);
https://user-images.githubusercontent.com/100898974/222066040-f6e737c6-ef07-4c35-ae96-bbc557e99cf1.mov
code :
GestureDetector(