Created
July 25, 2020 18:17
-
-
Save prasadshirvandkar/ccc4dc828a874740bf09192a0364c6c6 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:firebase_auth/firebase_auth.dart'; | |
class User { | |
String id; | |
String name; | |
String imageUrl; | |
String email; | |
String address; | |
User({this.id, this.name, this.imageUrl, this.email, this.address}); | |
factory User.create(FirebaseUser data) => User(id: data.uid, name: data.displayName, imageUrl: data.photoUrl, email: data.email); | |
factory User.fromMap(Map<String, dynamic> userInfoMap, String id) => User( | |
id: id ?? 'asd12e12q2d12f', | |
name: userInfoMap['name'] ?? 'No Name', | |
imageUrl: userInfoMap['imageUrl'] ?? 'Image URL', | |
email: userInfoMap['email'] ?? '[email protected]', | |
address: userInfoMap['address'] ?? 'No Address Found' | |
); | |
Map<String, dynamic> toMap() => { | |
'id': this.id, | |
'name': this.name, | |
'imageUrl': this.imageUrl, | |
'email': this.email, | |
'address': this.address | |
}; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment