@@ -6,41 +6,34 @@ import 'package:equatable/equatable.dart';
6
6
///
7
7
// ignore: must_be_immutable
8
8
class HabitRecord extends Equatable {
9
- final String objectId;
10
- final String userId;
11
9
final String habitId;
12
10
final int time;
13
11
final String content;
14
12
15
- HabitRecord (
16
- {this .time, this .content, this .habitId, this .userId, this .objectId});
13
+ HabitRecord ({this .time, this .content, this .habitId});
17
14
18
15
@override
19
16
String toString () {
20
- return 'HabitRecord{time: $time , content: $content , habitId: $habitId , userId: $ userId , objectId: $ objectId }' ;
17
+ return 'HabitRecord{time: $time , content: $content , habitId: $habitId }' ;
21
18
}
22
19
23
20
static HabitRecord fromJson (Map <String , dynamic > json) {
24
21
return HabitRecord (
25
22
habitId: json['habitId' ]? .toString (),
26
23
time: json["time" ]? .toInt (),
27
- content: json["content" ]? .toString (),
28
- userId: json['userId' ]? .toString (),
29
- objectId: json['objectId' ]? .toString ());
24
+ content: json["content" ]? .toString ());
30
25
}
31
26
32
27
Map <String , dynamic > toJson () {
33
28
final Map <String , dynamic > data = Map <String , dynamic >();
34
29
data['habitId' ] = habitId;
35
30
data["time" ] = time;
36
31
data["content" ] = content;
37
- data['userId' ] = userId;
38
- data['objectId' ] = objectId;
39
32
return data;
40
33
}
41
34
42
35
@override
43
- List <Object > get props => [habitId, time, content, userId, objectId ];
36
+ List <Object > get props => [habitId, time, content];
44
37
45
38
HabitRecord copyWith (
46
39
{String habitId,
@@ -51,22 +44,18 @@ class HabitRecord extends Equatable {
51
44
return HabitRecord (
52
45
habitId: habitId ?? this .habitId,
53
46
time: time ?? this .time,
54
- content: content ?? this .content,
55
- userId: userId ?? this .userId,
56
- objectId: objectId ?? this .objectId);
47
+ content: content ?? this .content);
57
48
}
58
49
}
59
50
60
51
// ignore: must_be_immutable
61
52
class Habit extends Equatable {
62
53
///唯一id uuid v4
63
- final String objectId;
64
54
final String id;
65
55
final String name;
66
56
final String iconPath;
67
57
final int mainColor;
68
58
final String mark;
69
- final String userId;
70
59
71
60
///提醒时间 每天 10: 20,eg
72
61
///转化为 json String 存储 ["10:20","11:50"]
@@ -101,8 +90,7 @@ class Habit extends Equatable {
101
90
final List <HabitRecord > records;
102
91
103
92
Habit (
104
- {this .objectId,
105
- this .id,
93
+ {this .id,
106
94
this .name,
107
95
this .iconPath,
108
96
this .mainColor,
@@ -115,12 +103,11 @@ class Habit extends Equatable {
115
103
this .modifyTime,
116
104
this .completed,
117
105
this .doNum,
118
- this .records,
119
- this .userId});
106
+ this .records});
120
107
121
108
@override
122
109
String toString () {
123
- return 'Habit{ objectId: $ objectId , id: $id , userId: $ userId , name: $name , iconPath: $iconPath , mainColor: '
110
+ return 'Habit{id: $id , name: $name , iconPath: $iconPath , mainColor: '
124
111
'$mainColor , mark: $mark , remindTimes: $remindTimes , completeTime:'
125
112
' $completeTime , completeDays: $completeDays , period: $period , '
126
113
'createTime: $createTime , modifyTime: $modifyTime , completed: $completed ,'
@@ -145,7 +132,6 @@ class Habit extends Equatable {
145
132
}
146
133
147
134
return Habit (
148
- objectId: json['objectId' ]? .toString (),
149
135
id: json["id" ]? .toString (),
150
136
name: json["name" ]? .toString (),
151
137
iconPath: json["iconPath" ]? .toString (),
@@ -159,13 +145,11 @@ class Habit extends Equatable {
159
145
modifyTime: json["modifyTime" ]? .toInt (),
160
146
completed: json["completed" ]? .toInt () == 1 ? true : false ,
161
147
doNum: json["doNum" ]? .toInt (),
162
- records: records,
163
- userId: json['userId' ]);
148
+ records: records);
164
149
}
165
150
166
151
Map <String , dynamic > toJson () {
167
152
final Map <String , dynamic > data = Map <String , dynamic >();
168
- data['objectId' ] = objectId;
169
153
data["id" ] = id;
170
154
data["name" ] = name;
171
155
data["iconPath" ] = iconPath;
@@ -195,7 +179,6 @@ class Habit extends Equatable {
195
179
data["modifyTime" ] = modifyTime;
196
180
data["completed" ] = completed ? 1 : 0 ;
197
181
data["doNum" ] = doNum;
198
- data['userId' ] = userId;
199
182
return data;
200
183
}
201
184
@@ -217,7 +200,6 @@ class Habit extends Equatable {
217
200
218
201
@override
219
202
List <Object > get props => [
220
- this .objectId,
221
203
this .id,
222
204
this .name,
223
205
this .iconPath,
@@ -232,7 +214,6 @@ class Habit extends Equatable {
232
214
this .completed,
233
215
this .doNum,
234
216
this .records,
235
- this .userId
236
217
];
237
218
238
219
Habit copyWith (
@@ -253,7 +234,6 @@ class Habit extends Equatable {
253
234
List <HabitRecord > records,
254
235
String userId}) {
255
236
return Habit (
256
- objectId: objectId ?? this .objectId,
257
237
id: id ?? this .id,
258
238
name: name ?? this .name,
259
239
iconPath: iconPath ?? this .iconPath,
@@ -267,7 +247,6 @@ class Habit extends Equatable {
267
247
modifyTime: modifyTime ?? this .modifyTime,
268
248
completed: completed ?? this .completed,
269
249
doNum: doNum ?? this .doNum,
270
- records: records ?? this .records,
271
- userId: userId ?? this .userId);
250
+ records: records ?? this .records);
272
251
}
273
252
}
0 commit comments