init
This commit is contained in:
commit
e833bcaec4
224 files changed
+11812
No files matched your search
@@ -0,0 +1,49 @@
|
||||
import 'contact.type.dart';
|
||||
|
||||
class Contact {
|
||||
final int id;
|
||||
final ContactType contactType;
|
||||
final String value;
|
||||
final int priority;
|
||||
final String notes;
|
||||
final DateTime creationDate;
|
||||
final DateTime? updateDate;
|
||||
final bool active;
|
||||
|
||||
Contact({
|
||||
required this.id,
|
||||
required this.contactType,
|
||||
required this.value,
|
||||
required this.priority,
|
||||
required this.notes,
|
||||
required this.creationDate,
|
||||
this.updateDate,
|
||||
required this.active,
|
||||
});
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
return {
|
||||
'id': id,
|
||||
'contactType': contactType.toJson(),
|
||||
'value': value,
|
||||
'priority': priority,
|
||||
'notes': notes,
|
||||
'creationDate': creationDate.toIso8601String(),
|
||||
'updateDate': updateDate?.toIso8601String(),
|
||||
'active': active,
|
||||
};
|
||||
}
|
||||
|
||||
factory Contact.fromJson(Map<String, dynamic> json) {
|
||||
return Contact(
|
||||
id: json['id'] as int,
|
||||
contactType: ContactType.fromJson(json['contactType'] as Map<String, dynamic>),
|
||||
value: json['value'] as String,
|
||||
priority: json['priority'] as int,
|
||||
notes: json['notes'] as String,
|
||||
creationDate: DateTime.parse(json['creationDate'] as String),
|
||||
updateDate: json['updateDate'] != null ? DateTime.parse(json['updateDate'] as String) : null,
|
||||
active: json['active'] as bool,
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user