sendMessage method
The action for the send message.
Implementation
@action
Future<void> sendMessage(
{required Function(ChatMessageSendOutput output) onSend}) async {
final output = ChatMessageSendOutput(
message: textEditingController.text,
imageFiles: _imageFiles.toList(),
);
if (config.loadingIndicatorType == LoadingIndicatorType.sendBtnLoading) {
_isSending = true;
try {
await onSend(output);
textEditingController.clear();
_imageFiles.clear();
} catch (e) {
Logger().e('Error occurred: $e');
}
_isSending = false;
} else {
try {
textEditingController.clear();
_imageFiles.clear();
onSend(output);
} catch (e) {
Logger().e('Error occurred: $e');
}
}
}