@@ -6,41 +6,34 @@ import 'package:equatable/equatable.dart';
66///
77// ignore: must_be_immutable
88class HabitRecord extends Equatable {
9- final String objectId;
10- final String userId;
119 final String habitId;
1210 final int time;
1311 final String content;
1412
15- HabitRecord (
16- {this .time, this .content, this .habitId, this .userId, this .objectId});
13+ HabitRecord ({this .time, this .content, this .habitId});
1714
1815 @override
1916 String toString () {
20- return 'HabitRecord{time: $time , content: $content , habitId: $habitId , userId: $ userId , objectId: $ objectId }' ;
17+ return 'HabitRecord{time: $time , content: $content , habitId: $habitId }' ;
2118 }
2219
2320 static HabitRecord fromJson (Map <String , dynamic > json) {
2421 return HabitRecord (
2522 habitId: json['habitId' ]? .toString (),
2623 time: json["time" ]? .toInt (),
27- content: json["content" ]? .toString (),
28- userId: json['userId' ]? .toString (),
29- objectId: json['objectId' ]? .toString ());
24+ content: json["content" ]? .toString ());
3025 }
3126
3227 Map <String , dynamic > toJson () {
3328 final Map <String , dynamic > data = Map <String , dynamic >();
3429 data['habitId' ] = habitId;
3530 data["time" ] = time;
3631 data["content" ] = content;
37- data['userId' ] = userId;
38- data['objectId' ] = objectId;
3932 return data;
4033 }
4134
4235 @override
43- List <Object > get props => [habitId, time, content, userId, objectId ];
36+ List <Object > get props => [habitId, time, content];
4437
4538 HabitRecord copyWith (
4639 {String habitId,
@@ -51,22 +44,18 @@ class HabitRecord extends Equatable {
5144 return HabitRecord (
5245 habitId: habitId ?? this .habitId,
5346 time: time ?? this .time,
54- content: content ?? this .content,
55- userId: userId ?? this .userId,
56- objectId: objectId ?? this .objectId);
47+ content: content ?? this .content);
5748 }
5849}
5950
6051// ignore: must_be_immutable
6152class Habit extends Equatable {
6253 ///唯一id uuid v4
63- final String objectId;
6454 final String id;
6555 final String name;
6656 final String iconPath;
6757 final int mainColor;
6858 final String mark;
69- final String userId;
7059
7160 ///提醒时间 每天 10: 20,eg
7261 ///转化为 json String 存储 ["10:20","11:50"]
@@ -101,8 +90,7 @@ class Habit extends Equatable {
10190 final List <HabitRecord > records;
10291
10392 Habit (
104- {this .objectId,
105- this .id,
93+ {this .id,
10694 this .name,
10795 this .iconPath,
10896 this .mainColor,
@@ -115,12 +103,11 @@ class Habit extends Equatable {
115103 this .modifyTime,
116104 this .completed,
117105 this .doNum,
118- this .records,
119- this .userId});
106+ this .records});
120107
121108 @override
122109 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: '
124111 '$mainColor , mark: $mark , remindTimes: $remindTimes , completeTime:'
125112 ' $completeTime , completeDays: $completeDays , period: $period , '
126113 'createTime: $createTime , modifyTime: $modifyTime , completed: $completed ,'
@@ -145,7 +132,6 @@ class Habit extends Equatable {
145132 }
146133
147134 return Habit (
148- objectId: json['objectId' ]? .toString (),
149135 id: json["id" ]? .toString (),
150136 name: json["name" ]? .toString (),
151137 iconPath: json["iconPath" ]? .toString (),
@@ -159,13 +145,11 @@ class Habit extends Equatable {
159145 modifyTime: json["modifyTime" ]? .toInt (),
160146 completed: json["completed" ]? .toInt () == 1 ? true : false ,
161147 doNum: json["doNum" ]? .toInt (),
162- records: records,
163- userId: json['userId' ]);
148+ records: records);
164149 }
165150
166151 Map <String , dynamic > toJson () {
167152 final Map <String , dynamic > data = Map <String , dynamic >();
168- data['objectId' ] = objectId;
169153 data["id" ] = id;
170154 data["name" ] = name;
171155 data["iconPath" ] = iconPath;
@@ -195,7 +179,6 @@ class Habit extends Equatable {
195179 data["modifyTime" ] = modifyTime;
196180 data["completed" ] = completed ? 1 : 0 ;
197181 data["doNum" ] = doNum;
198- data['userId' ] = userId;
199182 return data;
200183 }
201184
@@ -217,7 +200,6 @@ class Habit extends Equatable {
217200
218201 @override
219202 List <Object > get props => [
220- this .objectId,
221203 this .id,
222204 this .name,
223205 this .iconPath,
@@ -232,7 +214,6 @@ class Habit extends Equatable {
232214 this .completed,
233215 this .doNum,
234216 this .records,
235- this .userId
236217 ];
237218
238219 Habit copyWith (
@@ -253,7 +234,6 @@ class Habit extends Equatable {
253234 List <HabitRecord > records,
254235 String userId}) {
255236 return Habit (
256- objectId: objectId ?? this .objectId,
257237 id: id ?? this .id,
258238 name: name ?? this .name,
259239 iconPath: iconPath ?? this .iconPath,
@@ -267,7 +247,6 @@ class Habit extends Equatable {
267247 modifyTime: modifyTime ?? this .modifyTime,
268248 completed: completed ?? this .completed,
269249 doNum: doNum ?? this .doNum,
270- records: records ?? this .records,
271- userId: userId ?? this .userId);
250+ records: records ?? this .records);
272251 }
273252}
0 commit comments