copyWith method

User copyWith({
  1. int? id,
  2. String? institutionId,
  3. String? role,
  4. int? roleId,
  5. String? phoneNumber,
  6. String? fcmToken,
  7. DateTime? fcmTokenUpdatedAt,
  8. String? currentBlockName,
  9. int? currentBlockId,
  10. int? currentWardID,
  11. String? currentWardName,
  12. int? floor,
  13. int? hospitalId,
  14. bool? isApprover,
  15. bool? isSuperuser,
  16. bool? isResponder,
  17. bool? isCreator,
})

Creates a copy of this User object with the given fields replaced with new values.

This method is useful for creating a new User instance based on an existing one but with some properties modified, without directly mutating the original object.

Implementation

User copyWith({
  int? id,
  String? institutionId,
  String? role,
  int? roleId,
  String? phoneNumber,
  String? fcmToken,
  DateTime? fcmTokenUpdatedAt,
  String? currentBlockName,
  int? currentBlockId,
  int? currentWardID,
  String? currentWardName,
  int? floor,
  int? hospitalId,
  bool? isApprover,
  bool? isSuperuser,
  bool? isResponder,
  bool? isCreator,
}) {
  return User(
    id: id ?? this.id,
    institutionId: institutionId ?? this.institutionId,
    role: role ?? this.role,
    roleId: roleId ?? this.roleId,
    phoneNumber: phoneNumber ?? this.phoneNumber,
    fcmToken: fcmToken ?? this.fcmToken,
    fcmTokenUpdatedAt: fcmTokenUpdatedAt ?? this.fcmTokenUpdatedAt,
    currentBlockName: currentBlockName ?? this.currentBlockName,
    currentBlockId: currentBlockId ?? this.currentBlockId,
    currentWardID: currentWardID ?? this.currentWardID,
    currentWardName: currentWardName ?? this.currentWardName,
    floor: floor ?? this.floor,
    hospitalId: hospitalId ?? this.hospitalId,
    isApprover: isApprover ?? this.isApprover,
    isSuperuser: isSuperuser ?? this.isSuperuser,
    isResponder: isResponder ?? this.isResponder,
    isCreator: isCreator ?? this.isCreator,
  );
}