chatMessageFromJson function

List<ChatMessage> chatMessageFromJson(
  1. String str
)

Converts a JSON string into a list of ChatMessage objects.

This function decodes the provided JSON string into a list of maps, and then maps each item to a ChatMessage object using the ChatMessage.fromJson factory constructor.

str: The JSON string to be decoded.

Returns a list of ChatMessage objects.

Implementation

List<ChatMessage> chatMessageFromJson(String str) => List<ChatMessage>.from(
    json.decode(str).map((x) => ChatMessage.fromJson(x)));