copyWith method
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,
);