convertChatMessageJsonFromString function
Converts a nullable JSON string into a non-nullable JSON string representing a single chat message.
If the input string is null or empty, this function returns an empty string. Otherwise, it decodes the string into a ChatMessage object using sendMessageModelFromJson, and then serializes the object back into a JSON string using sendMessageModelToJson.
str
: The nullable JSON string to convert.
Returns a non-nullable JSON string.
Implementation
String convertChatMessageJsonFromString(String? str) =>
(str == null || str.isEmpty)
? ""
: sendMessageModelToJson(sendMessageModelFromJson(str));