re factor rog
This commit is contained in:
82
lib/features/data/checkpoint_visitis.dart
Normal file
82
lib/features/data/checkpoint_visitis.dart
Normal file
@ -0,0 +1,82 @@
|
||||
import 'dart:convert';
|
||||
|
||||
class CheckpointVisit {
|
||||
final String id;
|
||||
final String checkpointId;
|
||||
final String teamName;
|
||||
final String userName;
|
||||
final String eventCode;
|
||||
final DateTime visitTime;
|
||||
|
||||
CheckpointVisit({
|
||||
required this.id,
|
||||
required this.checkpointId,
|
||||
required this.teamName,
|
||||
required this.userName,
|
||||
required this.eventCode,
|
||||
required this.visitTime,
|
||||
});
|
||||
|
||||
CheckpointVisit copyWith({
|
||||
String? id,
|
||||
String? checkpointId,
|
||||
String? teamName,
|
||||
String? userName,
|
||||
String? eventCode,
|
||||
DateTime? visitTime,
|
||||
}) {
|
||||
return CheckpointVisit(
|
||||
id: id ?? this.id,
|
||||
checkpointId: checkpointId ?? this.checkpointId,
|
||||
teamName: teamName ?? this.teamName,
|
||||
userName: userName ?? this.userName,
|
||||
eventCode: eventCode ?? this.eventCode,
|
||||
visitTime: visitTime ?? this.visitTime,
|
||||
);
|
||||
}
|
||||
|
||||
Map<String, dynamic> toMap() {
|
||||
return {
|
||||
'id': id,
|
||||
'checkpointId': checkpointId,
|
||||
'teamName': teamName,
|
||||
'userName': userName,
|
||||
'eventCode': eventCode,
|
||||
'visitTime': visitTime.millisecondsSinceEpoch,
|
||||
};
|
||||
}
|
||||
|
||||
factory CheckpointVisit.fromMap(Map<String, dynamic> map) {
|
||||
return CheckpointVisit(
|
||||
id: map['id'],
|
||||
checkpointId: map['checkpointId'],
|
||||
teamName: map['teamName'],
|
||||
userName: map['userName'],
|
||||
eventCode: map['eventCode'],
|
||||
visitTime: DateTime.fromMillisecondsSinceEpoch(map['visitTime']),
|
||||
);
|
||||
}
|
||||
|
||||
String toJson() => json.encode(toMap());
|
||||
|
||||
factory CheckpointVisit.fromJson(String source) =>
|
||||
CheckpointVisit.fromMap(json.decode(source));
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'CheckpointVisit(id: $id, checkpointId: $checkpointId, teamName: $teamName, userName: $userName, eventCode: $eventCode, visitTime: $visitTime)';
|
||||
}
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
if (identical(this, other)) return true;
|
||||
|
||||
return other is CheckpointVisit &&
|
||||
other.id == id &&
|
||||
other.checkpointId == checkpointId &&
|
||||
other.teamName == teamName &&
|
||||
other.userName == userName &&
|
||||
other.eventCode == eventCode &&
|
||||
other.visitTime == visitTime;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user