ChatMessage.fromJson constructor
Creates a ChatMessage from a JSON representation.
The json
parameter should contain the required fields:
- 'id': String identifier
- 'content': String message content
- 'isUser': Boolean indicating if from user
- 'timestamp': ISO 8601 formatted date string
Throws a FormatException if the JSON is malformed.
Implementation
factory ChatMessage.fromJson(Map<String, dynamic> json) => ChatMessage(
id: json['id'] as String,
content: json['content'] as String,
isUser: json['isUser'] as bool,
timestamp: DateTime.parse(json['timestamp'] as String),
);