getSingleConversation method

Future<void> getSingleConversation(
  1. String id, {
  2. bool? track,
})

Implementation

Future<void> getSingleConversation(String id, {bool? track}) async {
  try {
    await getOfflineMessage(id);
    final response = await _conversationRepository.getConversations(id: id);

    if (response.status == 'success') {
      _conversationsService.conversation.value = response;
      individualConversationMessages.clear();
      update();
      individualConversationMessages.value = response.data!.messages ?? [];
      individualConversationMessages.refresh();

      update();
      _storageService.setString(id, jsonEncode(response.toJson()));

      isBlocked.value = response.data?.conversation?.contact?.isBlocked == "1"
          ? true
          : false;
      await getOfflineMessage(id);
      // update();
      update();

      if (scrollController.hasClients) {
        await scrollController.animateTo(
            scrollController.position.maxScrollExtent,
            duration: const Duration(milliseconds: 300),
            curve: Curves.easeOut);
      }
      getAllConversations();
      if (track != null && track == true) {}
      update();
    }
    update();
  } catch (e) {
    //log(e.toString());
  }
}