chatMessageToJson function

String chatMessageToJson(
  1. List<ChatMessage> data
)

Converts a list of ChatMessage objects into a JSON string.

This function takes each ChatMessage object in the provided list, converts it to a JSON map using the toJson method, and then encodes the list of maps as a JSON string.

data: The list of ChatMessage objects to be converted.

Returns a JSON string representation of the list of chat messages.

Implementation

String chatMessageToJson(List<ChatMessage> data) =>
    json.encode(List<dynamic>.from(data.map((x) => x.toJson())));