User.fromPayload constructor
User.fromPayload(
- Map<String, dynamic> parsedJson
)
Implementation
factory User.fromPayload(Map<String, dynamic> parsedJson) {
return new User(
email: parsedJson['email'] ?? '',
firstName: parsedJson['firstName'] ?? '',
lastName: parsedJson['lastName'] ?? '',
active: parsedJson['active'] ?? false,
lastOnlineTimestamp: DateTime.fromMillisecondsSinceEpoch(
parsedJson['lastOnlineTimestamp']),
settings: parsedJson.containsKey('settings')
? UserSettings.fromJson(parsedJson['settings'])
: UserSettings(),
phoneNumber: parsedJson['phoneNumber'] ?? '',
userID: parsedJson['id'] ?? parsedJson['userID'] ?? '',
profilePictureURL: parsedJson['profilePictureURL'] ?? '',
fcmToken: parsedJson['fcmToken'] ?? '',
photos: parsedJson['photos'] ?? [].cast<String>());
}