import 'package:cloud_firestore/cloud_firestore.dart'; import '../constants.dart'; import '../enumerations.dart'; import 'language.dart'; import 'location.dart'; class UserProfile { final String id; final String uid; final String email; String name; final String firstName; final String lastName; String? profilePictureUrl; String? bio; Gender? gender; int? born; final String risk; final List skills; final List skillsSought; List languages; Map locations; UserProfile({ required this.id, required this.uid, required this.email, required this.name, required this.firstName, required this.lastName, this.profilePictureUrl, this.bio, this.gender, this.born, required this.risk, required this.skills, required this.skillsSought, required this.languages, required this.locations, }); factory UserProfile.fromDocument(DocumentSnapshot doc) { Map data = doc.data() as Map; return UserProfile( id: doc.id, uid: data[Constants.dbFieldUsersID] ?? '', email: data[Constants.dbFieldUsersEmail] ?? '', name: data[Constants.dbFieldUsersName] ?? '', firstName: data[Constants.dbFieldUsersFirstName] ?? '', lastName: data[Constants.dbFieldUsersLastName] ?? '', skills: List.from(data[Constants.dbFieldUsersSkills] ?? []), skillsSought: List.from(data[Constants.dbFieldUsersSkillsSought] ?? []), risk: data[Constants.dbFieldUsersRiskTolerance] ?? '', profilePictureUrl: data[Constants.dbFieldUsersProfilePic], bio: data[Constants.dbFieldUsersBio], gender: Gender.values[data[Constants.dbFieldUsersGender] ?? 0], born: data[Constants.dbFieldUsersYearBorn], languages: [], locations: {}, ); } }