UserModel.fromJson constructor Null safety

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

Implementation

factory UserModel.fromJson(Map<String, dynamic> json) {
  final userModel = UserModel(
      year: json["year"],
      month: json["month"],
      day: json["day"],
      city: json["city"] == null ? null : CityModel.fromJson(json["city"]),
      isSubscribed: json["isSubscribed"],
      minAge: json["minAge"],
      id: json["id"],
      firstName: json["firstName"],
      lastName: json["lastName"],
      mobile: json["mobile"],
      email: json["email"],
      isActive: json["isActive"],
      zoneId: json["zoneID"],
      gender: Gender.values.elementAt(json["gender"]));
  // json["gender"] == null ? null : json["gender"]);
  return userModel;
}