Files
GSFV2/gsf/lib/modals/user_model.dart
2024-04-10 12:51:20 +05:30

68 lines
2.0 KiB
Dart

class UserModel {
final int id;
final String? token;
final String name;
final String phoneNo;
final String email;
final String? profilePicUrl;
final String? bio;
final String? gender;
final int? age;
final String? address;
final String? city;
final double? height;
// final double? weight;
const UserModel({
required this.id,
required this.token,
required this.name,
required this.phoneNo,
required this.email,
this.profilePicUrl,
this.bio,
this.gender,
this.age,
this.address,
this.city,
this.height,
// this.weight,
});
factory UserModel.fromJson(Map<String, dynamic> json) {
Map<String, dynamic>? userDetails =
json["authorisation"]["user_data"]["user_detail"];
return UserModel(
id: json["authorisation"]["user_data"]["id"],
token: json["authorisation"]["token"],
name: json["authorisation"]["user_data"]["full_name"],
phoneNo: json["authorisation"]["user_data"]["contact_number"],
email: json["authorisation"]["user_data"]["email_id"],
profilePicUrl:
userDetails == null ? null : userDetails["profile_picture"],
address: userDetails == null || userDetails["full_address"] == null
? null
: userDetails["full_address"],
age: userDetails == null || userDetails["age"] == null
? null
: userDetails["age"],
bio: userDetails == null || userDetails["user_bio"] == null
? null
: userDetails["user_bio"],
city: userDetails == null || userDetails["city"] == null
? null
: userDetails["city"],
gender: userDetails == null || userDetails["gender"] == null
? null
: userDetails["gender"],
height: userDetails == null || userDetails["height"] == null
? null
: double.parse(userDetails["height"].toString()),
// weight: userDetails == null
// ? null
// : double.parse(userDetails["weight"].toString()),
);
}
}