sendAnonymously method

Future<void> sendAnonymously({
  1. required String message,
})

Sends a message anonymously which does not appear in the chat history

Implementation

Future<void> sendAnonymously({required String message}) async {
  try {
    assert(message.isNotEmpty, "Message cannot be empty");
    if (message.isEmpty) return;
    textEditingController.clear();
    isLoading = true;
    notifyListeners();
    final responseMessage =
        await _apiDatasource.sendMessage(message: message);
    messages.add(responseMessage);
  } catch (e) {
    _handleUnexpectedError('Unexpected error occurred: $e');
  } finally {
    isLoading = false;
    notifyListeners();
  }
}