서버 연결 ã 코드 작성ì중
This commit is contained in:
29
lib/models/chat_message.dart
Normal file
29
lib/models/chat_message.dart
Normal file
@@ -0,0 +1,29 @@
|
||||
class ChatMessage {
|
||||
final String text;
|
||||
final bool isUser;
|
||||
final DateTime timestamp;
|
||||
|
||||
ChatMessage({
|
||||
required this.text,
|
||||
required this.isUser,
|
||||
required this.timestamp,
|
||||
});
|
||||
|
||||
// JSON에서 ChatMessage로 변환
|
||||
factory ChatMessage.fromJson(Map<String, dynamic> json) {
|
||||
return ChatMessage(
|
||||
text: json['text'] as String,
|
||||
isUser: json['isUser'] as bool,
|
||||
timestamp: DateTime.parse(json['timestamp'] as String),
|
||||
);
|
||||
}
|
||||
|
||||
// ChatMessage를 JSON으로 변환
|
||||
Map<String, dynamic> toJson() {
|
||||
return {
|
||||
'text': text,
|
||||
'isUser': isUser,
|
||||
'timestamp': timestamp.toIso8601String(),
|
||||
};
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user