import '../clients/service_users_model.dart'; import 'LocationData.dart'; class UserData { UserData({ this.location, this.id, this.userModelName, this.name, this.version, this.email, this.phoneNumber, this.active, this.role, this.profilePictureUrl, this.profileVideoUrl, this.deviceId, this.verificationCode, this.isVerified, this.approved, this.blocked, this.createdAt, this.updatedAt, this.userSettings, this.modelId, }); UserData.fromJson(dynamic json) { location = json['location'] is Map ? LocationData.fromJson(json['location']) : null; id = json['_id']; userModelName = json['userModelName']; name = json['name']; version = json['version']; email = json['email']; phoneNumber = json['phoneNumber']; active = json['active']; role = json['role']; profilePictureUrl = json['profile_picture_url']; profileVideoUrl = json['profile_video_url']; deviceId = json['deviceId']; verificationCode = json['verification_code']; isVerified = json['is_verified']; approved = json['approved']; blocked = json['blocked']; createdAt = json['createdAt']; updatedAt = json['updatedAt']; userSettings = json['userSettings'] is String ? json['userSettings'] : null; modelId = json['modelId'] is Map ? ServiceUserModel.fromJson(json['modelId']) : null; } LocationData? location; String? id; String? userModelName; String? name; String? version; String? email; String? phoneNumber; bool? active; String? role; String? profilePictureUrl; String? profileVideoUrl; String? deviceId; String? verificationCode; bool? isVerified; bool? approved; bool? blocked; String? createdAt; String? updatedAt; String? userSettings; ServiceUserModel? modelId; String get displayName => (_fullName.trim().isNotEmpty) ? _fullName.trim() : (name ?? ""); String get _fullName => "${modelId?.suFirstMiddleName ?? ""} ${modelId?.suLastName ?? ""}"; Map toJson() { final map = {}; if (location != null) { map['location'] = location?.toJson(); } map['_id'] = id; map['userModelName'] = userModelName; map['name'] = name; map['version'] = version; map['email'] = email; map['phoneNumber'] = phoneNumber; map['active'] = active; map['role'] = role; map['profile_picture_url'] = profilePictureUrl; map['profile_video_url'] = profileVideoUrl; map['deviceId'] = deviceId; map['verification_code'] = verificationCode; map['is_verified'] = isVerified; map['approved'] = approved; map['blocked'] = blocked; map['createdAt'] = createdAt; map['updatedAt'] = updatedAt; map['userSettings'] = userSettings; map['modelId'] = modelId; return map; } }