loadPreviousMessages method

  1. @override
Future<void> loadPreviousMessages(
  1. dynamic callback(
    1. FlyResponse response
    )
)
override

This method is used to load the previous messages.

Implementation

@override
Future<void> loadPreviousMessages(
    Function(FlyResponse response) callback) async {
  String? previousMessageResponse;
  try {
    previousMessageResponse =
        await mirrorFlyMethodChannel.invokeMethod('loadPreviousMessages');
    var res = convertChatMessagesJsonFromString(previousMessageResponse);
    callback.call(FlyResponse(true, res, "load previous messages fetched"));
  } on PlatformException catch (e) {
    LogMessage.d("Platform Exception =", " $e");
    callback.call(FlyResponse(false, FlyConstants.empty, FlyConstants.empty,
        FlyException(e.code, e.message, e.details)));
  } on Exception catch (e) {
    LogMessage.d("Exception ", " $e");
    callback.call(FlyResponse(false, FlyConstants.empty, FlyConstants.empty,
        FlyException(FlyErrorCode.unHandle, FlyErrorMessage.unHandle, e)));
  }
}