Guest User

Untitled

a guest
Oct 20th, 2018
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.52 KB | None | 0 0
  1. class ChatRoom {
  2.  
  3.  
  4. List<User> members = List<User>();
  5. String chatRoomId;
  6. String key;
  7. String roomTitle;
  8. String lastMessage;
  9. FieldValue timestamp;
  10. String chatType;
  11. List<User> newMembers;
  12.  
  13. ChatRoom(this.members, this.chatRoomId, this.roomTitle, this.lastMessage, this.timestamp, this.chatType);
  14.  
  15.  
  16.  
  17. Map<String, dynamic> toJson() {
  18. return {
  19. "members": newMembers = members.map((User user) {
  20. return user.toJson().cast<User>();
  21. }).toList(),
  22. "chatRoomId": chatRoomId,
  23. "roomTitle": roomTitle,
  24. "timestamp": timestamp,
  25. "chatType": chatType,
  26. "lastMessage": lastMessage,
  27. };
  28. }
  29.  
  30. }
  31.  
  32. class User {
  33.  
  34.  
  35.  
  36. String key;
  37. String firstName;
  38. String uid;
  39. String lastName;
  40. String email;
  41. String city;
  42. int age;
  43. int dateOfBirth;
  44. String gender;
  45. String profilePic;
  46. String hereFor;
  47. String seeking;
  48. String sexualOrientation;
  49. String aboutMe;
  50. String lookingPartner;
  51. String maritalStatus;
  52. String country;
  53. String username;
  54. int minage;
  55. int maxage;
  56. String fcmToken;
  57. bool invisible;
  58. double distance;
  59. String work;
  60. List<String> hobbies;
  61. bool hasKids;
  62. bool verified;
  63.  
  64.  
  65. User(this.firstName, this.uid, this.lastName, this.email, this.city,
  66. this.age, this.dateOfBirth, this.gender, this.profilePic, this.hereFor,
  67. this.seeking, this.sexualOrientation, this.aboutMe, this.lookingPartner,
  68. this.maritalStatus, this.country, this.username, this.minage, this.maxage,
  69. this.fcmToken, this.invisible, this.distance, this.work, this.hasKids, this.hobbies, this.verified);
  70.  
  71. User.fromSnapshot(DocumentSnapshot snapshot) :
  72. key = snapshot.documentID,
  73. firstName = snapshot.data['firstName'],
  74. lastName = snapshot.data['lastName'],
  75. uid = snapshot.data['uid'],
  76. email = snapshot.data['email'],
  77. city = snapshot.data['city'],
  78. age = snapshot.data['age'],
  79. dateOfBirth = snapshot.data['dateOfBirth'],
  80. gender = snapshot.data['gender'],
  81. profilePic = snapshot.data['profilePic'],
  82. hereFor = snapshot.data['hereFor'],
  83. seeking = snapshot.data['seeking'],
  84. sexualOrientation = snapshot.data['sexualOrientation'],
  85. aboutMe = snapshot.data['aboutMe'],
  86. lookingPartner = snapshot.data['lookingPartner'],
  87. maritalStatus = snapshot.data['maritalStatus'],
  88. country = snapshot.data['country'],
  89. username = snapshot.data['username'],
  90. work = snapshot.data['work'] ?? 'N/A',
  91. hasKids = snapshot.data['hasKids'] ?? false,
  92. verified = snapshot.data['verified'] ?? false,
  93. hobbies = List<String>.from(snapshot.data['hobbies']),
  94. minage = snapshot.data['minage'],
  95. maxage = snapshot.data['maxage'],
  96. fcmToken = snapshot.data['fcmToken'],
  97. distance = snapshot.data['distance'],
  98. invisible = snapshot.data['invisible'];
  99.  
  100. toJson() {
  101. return {
  102. "uid": uid,
  103. "firstName": firstName,
  104. "lastName": lastName,
  105. "age": age,
  106. "city": city,
  107. "dateOfBirth": dateOfBirth,
  108. "gender": gender,
  109. "profilePic": profilePic,
  110. "email": email,
  111. "hereFor": hereFor,
  112. "seeking": seeking,
  113. "sexualOrientation": sexualOrientation,
  114. "aboutMe": aboutMe,
  115. "lookingPartner": lookingPartner,
  116. "maritalStatus": maritalStatus,
  117. "country": country,
  118. "username": username,
  119. "maxage": maxage,
  120. "hobbies": hobbies,
  121. "verified": verified,
  122. "hasKids": hasKids,
  123. "work": work,
  124. "minage": minage,
  125. "distance": distance,
  126. "fcmToken": fcmToken,
  127. "invisible": invisible
  128. };
  129. }
  130.  
  131. }
Add Comment
Please, Sign In to add comment