Deploy: 2026-05-24 23:27:32
This commit is contained in:
58
mobile/lib/features/dashboard/data/models/contact_model.dart
Normal file
58
mobile/lib/features/dashboard/data/models/contact_model.dart
Normal file
@@ -0,0 +1,58 @@
|
||||
import 'package:equatable/equatable.dart';
|
||||
|
||||
class ContactModel extends Equatable {
|
||||
// English: Unique identifier for the contact.
|
||||
// Arabic: المعرف الفريد لجهة الاتصال.
|
||||
final int id;
|
||||
|
||||
// English: Name of the contact.
|
||||
// Arabic: اسم جهة الاتصال.
|
||||
final String name;
|
||||
|
||||
// English: Phone number.
|
||||
// Arabic: رقم الهاتف.
|
||||
final String phone;
|
||||
|
||||
// English: Optional email address.
|
||||
// Arabic: البريد الإلكتروني الاختياري.
|
||||
final String? email;
|
||||
|
||||
// English: Optional descriptive notes.
|
||||
// Arabic: ملاحظات وصفية اختيارية.
|
||||
final String? notes;
|
||||
|
||||
const ContactModel({
|
||||
required this.id,
|
||||
required this.name,
|
||||
required this.phone,
|
||||
this.email,
|
||||
this.notes,
|
||||
});
|
||||
|
||||
// English: Factory constructor to parse ContactModel from JSON map.
|
||||
// Arabic: منشئ المصنع لتحليل نموذج جهة الاتصال من خريطة جيسون.
|
||||
factory ContactModel.fromJson(Map<String, dynamic> json) {
|
||||
return ContactModel(
|
||||
id: json['id'] as int? ?? 0,
|
||||
name: json['name'] as String? ?? '',
|
||||
phone: json['phone'] as String? ?? '',
|
||||
email: json['email'] as String?,
|
||||
notes: json['notes'] as String?,
|
||||
);
|
||||
}
|
||||
|
||||
// English: Convert model to JSON map.
|
||||
// Arabic: تحويل النموذج إلى خريطة جيسون.
|
||||
Map<String, dynamic> toJson() {
|
||||
return {
|
||||
'id': id,
|
||||
'name': name,
|
||||
'phone': phone,
|
||||
'email': email,
|
||||
'notes': notes,
|
||||
};
|
||||
}
|
||||
|
||||
@override
|
||||
List<Object?> get props => [id, name, phone, email, notes];
|
||||
}
|
||||
Reference in New Issue
Block a user