convertChatMessagesJsonFromString function

String convertChatMessagesJsonFromString(
  1. String? str
)

Converts a nullable JSON string into a non-nullable JSON string representing a list of chat messages.

If the input string is null or empty, this function returns an empty string. Otherwise, it decodes the string into a list of ChatMessage objects using chatMessageFromJson, and then serializes the list back into a JSON string using chatMessageToJson.

str: The nullable JSON string to convert.

Returns a non-nullable JSON string.

Implementation

String convertChatMessagesJsonFromString(String? str) =>
    (str == null || str.isEmpty)
        ? ""
        : chatMessageToJson(chatMessageFromJson(str));