User.fromJson constructor

User.fromJson(
  1. Map<String, dynamic> json
)

Implementation

factory User.fromJson(Map<String, dynamic> json) {
  return User(
    sId: json['_id'],
    status: json['status'],
    isVerified: json['isVerified'],
    fullName: json['fullName'],
    // userMedia: (json['photos_videos'] as List?)
    //     ?.map((e) => UserProfileMedia.fromMap(e))
    //     .toList(),
    // countryData: json['countryId'] != null
    //     ? CountryData.fromJson(json['countryId'])
    //     : null,
    mobileNo: json['mobileNo'],
    gender: json['gender'],
    // age: json['dateOfBirth'] is int
    //     ? json['dateOfBirth']
    //     : json['dateOfBirth'] is String
    //         ? DobValidation.calculateAge(DateTime.parse(json['dateOfBirth']))
    //         : null,
    dateOfBirth: json['dateOfBirth'] is String
        ? DateTime.parse(json['dateOfBirth'])
        : null,
    createdAt:
        json['createdAt'] != null ? DateTime.parse(json['createdAt']) : null,
    // interests: (json['interests'] is List)
    //     ? (json['interests'] as List).map((v) {
    //         if (v is String) return Interests(interest: v);
    //         return Interests.fromJson(v);
    //       }).toList()
        // : null,
    bio: json['bio'],
    connectionsCount: json['connectionsCount'] ?? 0,
    countryFlag: json['userCountryFlag'],
    countryName: json['userCountryName'],
    isOnline: json['isOnline'],
    socialAccountsList: (json['social'] as Map?)
        ?.entries
        .map((e) => SocialAccounts.fromString(e.key))
        .toList(),
    type: UserType.fromString(json['status']),
    loginMethodType: json['signUpType'] != null
        ? LoginMethodType.fromString(json['signUpType'])
        : null,
  );
}