Created
October 6, 2019 19:18
-
-
Save adityadroid/b3dc27c4db0656ab60b13d0e32df378d to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import 'package:cloud_firestore/cloud_firestore.dart'; | |
| import 'package:messio/models/Conversation.dart'; | |
| class Contact { | |
| String username; | |
| String name; | |
| String photoUrl; | |
| String documentId; | |
| String chatId; | |
| Contact(this.documentId, this.username, this.name,this.photoUrl, this.chatId); | |
| factory Contact.fromFirestore(DocumentSnapshot doc) { | |
| Map data = doc.data; | |
| return Contact(doc.documentID, data['username'], data['name'],data['photoUrl'], data['chatId']); | |
| } | |
| @override | |
| String toString() { | |
| return '{ documentId: $documentId, name: $name, username: $username, photoUrl: $photoUrl , chatId: $chatId}'; | |
| } | |
| String getFirstName() => name.split(' ')[0]; | |
| String getLastName() { | |
| List names = name.split(' '); | |
| return names.length > 1 ? names[1] : ''; | |
| } | |
| factory Contact.fromConversation(Conversation conversation) { | |
| return Contact(conversation.user.documentId, conversation.user.username, | |
| conversation.user.name,conversation.user.photoUrl,conversation.chatId,); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment