ChatUser.fromJson constructor

ChatUser.fromJson(
  1. Map<String, dynamic> json, {
  2. ChatUserConfigBase? config,
})

Implementation

factory ChatUser.fromJson(
  Map<String, dynamic> json, {
  ChatUserConfigBase? config,
}) {
  final idKey = config?.idKey ?? _idKey;
  final nameKey = config?.nameKey ?? _nameKey;
  final profilePhotoKey = config?.profilePhotoKey ?? _profilePhotoKey;
  return ChatUser(
    id: json[idKey]?.toString() ?? '',
    name: json[nameKey]?.toString() ?? '',
    profilePhoto: json[profilePhotoKey]?.toString(),
    imageType: ImageType.tryParse(json['imageType']?.toString()) ??
        ImageType.network,
    defaultAvatarImage:
        json['defaultAvatarImage']?.toString() ?? Constants.profileImage,
  );
}