copyWith method

User copyWith({
  1. String? id,
  2. String? role,
  3. String? name,
  4. String? image,
  5. DateTime? createdAt,
  6. DateTime? updatedAt,
  7. DateTime? lastActive,
  8. bool? online,
  9. Map<String, Object?>? extraData,
  10. bool? banned,
  11. DateTime? banExpires,
  12. List<String>? teams,
  13. String? language,
})

Creates a copy of User with specified attributes overridden.

Implementation

User copyWith({
  String? id,
  String? role,
  String? name,
  String? image,
  DateTime? createdAt,
  DateTime? updatedAt,
  DateTime? lastActive,
  bool? online,
  Map<String, Object?>? extraData,
  bool? banned,
  DateTime? banExpires,
  List<String>? teams,
  String? language,
}) =>
    User(
      id: id ?? this.id,
      role: role ?? this.role,
      name: name ??
          extraData?['name'] as String? ??
          // Using extraData value in order to not use id as name.
          this.extraData['name'] as String?,
      image: image ?? extraData?['image'] as String? ?? this.image,
      createdAt: createdAt ?? this.createdAt,
      updatedAt: updatedAt ?? this.updatedAt,
      lastActive: lastActive ?? this.lastActive,
      online: online ?? this.online,
      extraData: extraData ?? this.extraData,
      banned: banned ?? this.banned,
      banExpires: banExpires ?? this.banExpires,
      teams: teams ?? this.teams,
      language: language ?? this.language,
    );