File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ class Message {
2+ final String id;
3+ final String senderId;
4+ final String receiverId;
5+ final String content;
6+ final DateTime createdAt;
7+
8+ Message ({
9+ required this .id,
10+ required this .senderId,
11+ required this .receiverId,
12+ required this .content,
13+ required this .createdAt,
14+ });
15+
16+ factory Message .fromJson (Map <String , dynamic > json) {
17+ return Message (
18+ id: json['id' ],
19+ senderId: json['sender_id' ],
20+ receiverId: json['receiver_id' ],
21+ content: json['content' ],
22+ createdAt: DateTime .parse (json['created_at' ]),
23+ );
24+ }
25+
26+ factory Message .fromMap (Map <String , dynamic > map) {
27+ return Message (
28+ id: map['id' ],
29+ senderId: map['sender_id' ],
30+ receiverId: map['receiver_id' ],
31+ content: map['content' ],
32+ createdAt: DateTime .parse (map['created_at' ]),
33+ );
34+ }
35+
36+ Map <String , dynamic > toMap () => {
37+ 'id' : id,
38+ 'sender_id' : senderId,
39+ 'receiver_id' : receiverId,
40+ 'content' : content,
41+ 'created_at' : createdAt.toIso8601String (),
42+ };
43+ }
You can’t perform that action at this time.
0 commit comments