historyScrollListener method

dynamic historyScrollListener()

Implementation

historyScrollListener() {
  if (historyScrollController.position.pixels ==
      historyScrollController.position.maxScrollExtent) {
    if (!isRecentHistoryLoading.value) {
      recentChatPage++;
      isRecentHistoryLoading(true);
      debugPrint("calling page no $recentChatPage");
      callback(FlyResponse response) {
        if (response.isSuccess && response.hasData) {
          debugPrint("getRecentChatListHistory next data ${response.data}");
          var data = recentChatFromJson(response
              .data); //await compute(recentChatFromJson, value.toString());
          LogMessage.d("getRecentChatListHistory", data.toJson());
          recentChats.addAll(data.data!);
          recentChats.refresh();
          isRecentHistoryLoading(false);
          getArchivedChatsList();
        } else {
          debugPrint("recent chat issue===> ${response.exception}");
          isRecentHistoryLoading(false);
        }
      }

      Mirrorfly.getRecentChatListHistory(
          firstSet: recentChatPage == 1,
          limit: chatLimit,
          flyCallback: callback);
    }
  }
  if (historyScrollController.position.pixels ==
      historyScrollController.position.minScrollExtent) {
    debugPrint("historyScrollController reached top");
  }
}