import 'package:cloud_firestore/cloud_firestore.dart'; class DepotModel { final String id; final String name; final String address; final DateTime? createdAt; const DepotModel({ required this.id, required this.name, required this.address, this.createdAt, }); factory DepotModel.fromMap(Map map, String id) { return DepotModel( id: id, name: (map['name'] ?? '').toString(), address: (map['address'] ?? '').toString(), createdAt: map['createdAt'] is Timestamp ? (map['createdAt'] as Timestamp).toDate() : null, ); } factory DepotModel.fromFirestore(DocumentSnapshot doc) { return DepotModel.fromMap(doc.data() as Map, doc.id); } Map toMap() { return { 'name': name, 'address': address, 'createdAt': createdAt != null ? Timestamp.fromDate(createdAt!) : FieldValue.serverTimestamp(), }; } DepotModel copyWith({String? id, String? name, String? address}) { return DepotModel( id: id ?? this.id, name: name ?? this.name, address: address ?? this.address, createdAt: createdAt, ); } }