onAnimatedButtonLongPressEnd method
animated button on long press end -> stop and either send or cancel
Implementation
void onAnimatedButtonLongPressEnd(LongPressEndDetails details) async {
if (isText || !_isRecording) return;
final source = await stopRecord();
_stopWatchTimer.onStopTimer();
_stopWatchTimer.onResetTimer();
if (_position > cancelPosition - _height || source == null) {
handleRecord(null, true);
onSlideToCancelRecord();
} else {
final audioMessage = ChatMessage(
text: '',
isSender: true,
chatMedia: ChatMedia(url: source, mediaType: MediaType.audio),
);
handleRecord(audioMessage, false);
}
_duration = 600;
_position = 0;
_isRecording = false;
notifyListeners();
}