Report.fromMap constructor

Report.fromMap(
  1. Map<String, dynamic> map,
  2. String id
)

//////////// //////////// Creates a Report from a Firestore document map

Implementation

// II.C - Factory Methods
///////////////
/// Creates a Report from a Firestore document map
factory Report.fromMap(Map<String, dynamic> map, String id) {
  return Report(
    id: id,
    type: map['type'] ?? 'unknown',
    location: map['location'] as GeoPoint? ?? GeoPoint(0, 0),
    geohash: map['geohash'] as String?,
    createdBy: map['createdBy'] ?? '',
    createdAt: map['createdAt'] as Timestamp? ?? Timestamp.now(),
    expiresAt: map['expiresAt'] as Timestamp? ?? Timestamp.now(),
    direction: map['direction'] ?? 0,
    lane: map['lane'] ?? 0,
    suggestedAlternative: map['suggestedAlternative'] ?? 'none',
    details: Map<String, dynamic>.from(map['details'] ?? {}),
  );
}