FileMessage.fromJson constructor

FileMessage.fromJson(
  1. Map<String, dynamic> json
)

Implementation

factory FileMessage.fromJson(Map<String, dynamic> json) {
  final Map<String, dynamic>? file = json['file'];
  if (file != null) {
    json['url'] = file['url'];
    json['type'] = file['type'];
    json['size'] = file['size'];
    json['name'] = file['name'];
    json['data'] = file['data'];
    json['require_auth'] = json['require_auth'] ?? file['require_auth'];
  }

  FileMessage fileMessage = _$FileMessageFromJson(json)
    ..set(SendbirdChat().chat); // Set the singleton chat

  // Scheduled message
  if (json['scheduled_message_id'] != null) {
    fileMessage.scheduledInfo = ScheduledInfo.fromJson(json);
  }
  return fileMessage;
}