copyWith method
Creates a copy of this user with the given fields replaced.
All parameters are optional — omitted fields retain their current values.
final updated = user.copyWith(isNotificationsEnabled: false);
Implementation
UserModel copyWith({
int? id,
String? firstName,
String? lastName,
String? email,
String? profileImageUrl,
bool? isNotificationsEnabled,
DateTime? emailVerifiedAt,
DateTime? createdAt,
DateTime? updatedAt,
}) {
return UserModel(
id: id ?? this.id,
firstName: firstName ?? this.firstName,
lastName: lastName ?? this.lastName,
email: email ?? this.email,
profileImageUrl: profileImageUrl ?? this.profileImageUrl,
isNotificationsEnabled: isNotificationsEnabled ?? this.isNotificationsEnabled,
emailVerifiedAt: emailVerifiedAt ?? this.emailVerifiedAt,
createdAt: createdAt ?? this.createdAt,
updatedAt: updatedAt ?? this.updatedAt,
);
}