1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
import 'package:flutter/material.dart';
import 'package:gmalpha_flutter/commonModel/list_item.dart';
import 'package:gmalpha_flutter/messageModel/model/message/replied_content.dart';
// The base class for the different types of items the list can contain.
// abstract class ListItem {}
// https://javiercbk.github.io/json_to_dart/ json 在线转dart
class Message implements ListItem {
final int userId;
final String name;
final String icon;
final num time;
final String content;
final int id;
// final String repliedContent;
final RepliedContent repliedContent;
Message(
{this.userId,
this.name,
this.icon,
this.time,
this.content,
this.id,
this.repliedContent,
});
factory Message.fromJson(Map<String, dynamic> json) {
return Message(
userId: json['user_id'],
name: json['name'],
icon: json['icon'],
id: json['id'],
time: json['time'],
content: json['content'],
repliedContent: json['replied_content'] != null ? new RepliedContent.fromJson(json['replied_content']):null,
);
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
data['user_id'] = this.userId;
data['name'] = this.name;
data['icon'] = this.icon;
data['id'] = this.id;
data['time'] = this.time;
data['content'] = this.content;
if (this.repliedContent != null) {
data['replied_content'] = this.repliedContent.toJson();
}
return data;
}
}
class NotificationItem implements ListItem {
String icon;
String content;
int count;
String title;
NotificationItem(this.icon, this.content, this.count, this.title);
}