From e86d882e8cda09ad97267c175b394a43ae4125aa Mon Sep 17 00:00:00 2001 From: Hadi Mottale Date: Wed, 11 Jun 2025 10:39:17 +0330 Subject: [PATCH] Feat: Data Model Added --- lib/models/contact.dart | 48 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 lib/models/contact.dart diff --git a/lib/models/contact.dart b/lib/models/contact.dart new file mode 100644 index 0000000..07829fa --- /dev/null +++ b/lib/models/contact.dart @@ -0,0 +1,48 @@ +class Contact { + int? id; + String name; + String? phone; + String? email; + String? address; + String? company; + String? notes; + + Contact({ + this.id, + required this.name, + this.phone, + this.email, + this.address, + this.company, + this.notes, + }); + + Map toMap() { + return { + 'id': id, + 'name': name, + 'phone': phone, + 'email': email, + 'address': address, + 'company': company, + 'notes': notes, + }; + } + + factory Contact.fromMap(Map map) { + return Contact( + id: map['id'], + name: map['name'], + phone: map['phone'], + email: map['email'], + address: map['address'], + company: map['company'], + notes: map['notes'], + ); + } + + @override + String toString() { + return 'Contact{id: $id, name: $name, phone: $phone, email: $email, address: $address, company: $company, notes: $notes}'; + } +}