RaliUser.fromMap constructor

RaliUser.fromMap(
  1. Map<String, dynamic> map,
  2. String uid
)

//////////// //////////// Creates a RaliUser from a Firestore document map

Implementation

// II.C - Factory Methods
///////////////
/// Creates a RaliUser from a Firestore document map
factory RaliUser.fromMap(Map<String, dynamic> map, String uid) {
  return RaliUser(
    uid: uid,
    displayName: map['displayName'] ?? 'User',
    email: map['email'] ?? '',
    photoURL: map['photoURL'],
    preferences: Map<String, dynamic>.from(map['preferences'] ?? {}),
    savedDestinations: (map['savedDestinations'] as List<dynamic>?)
        ?.map((e) => Map<String, dynamic>.from(e))
        .toList() ?? [],
    savedRoutes: List<String>.from(map['savedRoutes'] ?? []),
    createdAt: map['createdAt'] as Timestamp? ?? Timestamp.now(),
    lastLogin: map['lastLogin'] as Timestamp? ?? Timestamp.now(),
  );
}