'Flutter GestureDetector onTapDown/onTapUp, silde finger off pointer
I am having this weird issue with the onTapDown/onTapUp.
I am using the tap down for a voicenote so while holding it down it should record and when lifting it should stop.
However, when I hold the button down and slide my finger off the button's pointer the button's function keeps running. and the only way to stop it is to hold down the button again and then release it.
it there a way to check to see if a user's finger is out of the button's pointer and the stop the recording?
GestureDetector(
onTapDown: (_) => _record(),
onTapUp: (_) => _stopRecorder().then((value) => setState(() {})),
child: Icon(_recorder!.isRecording ? Icons.stop : Icons.mic_none_outlined, color: _recorder!.isRecording ? AppColor.mathPink : AppColor.mainBlack),
),
Solution 1:[1]
This was the solution
GestureDetector(
onTapCancel: () => _stopRecorder().then((value) => setState(() {})),
onTapDown: (_) => _record(),
onTapUp: (_) => _stopRecorder().then((value) => setState(() {})),
child: Icon(_recorder!.isRecording ? Icons.stop : Icons.mic_none_outlined, color: _recorder!.isRecording ? AppColor.mathPink : AppColor.mainBlack),
),
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Morne du Toit |
