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,
      // if null, it will be retrieved from extraData['name']
      name: name,
      // if null, it will be retrieved from extraData['image']
      image: 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,
    );