copyWith method

UserModel copyWith({
  1. int? id,
  2. String? firstName,
  3. String? lastName,
  4. String? email,
  5. String? profileImageUrl,
  6. bool? isNotificationsEnabled,
  7. DateTime? emailVerifiedAt,
  8. DateTime? createdAt,
  9. DateTime? updatedAt,
})

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,
  );
}