chatMessageModelToJson function
Converts a list of ChatMessageModel objects into a JSON string.
This function takes a list of ChatMessageModel objects, converts each into a map
using the toJson
method, and then encodes this list of maps as a JSON string.
Parameters:
data
- The list of ChatMessageModel objects to be converted into a JSON string.
Returns: A JSON string representation of the list of ChatMessageModel objects.
Implementation
String chatMessageModelToJson(List<ChatMessageModel> data) =>
json.encode(List<dynamic>.from(data.map((x) => x.toJson())));