toJson method Null safety

Map<String, dynamic> toJson()

Implementation

Map<String, dynamic> toJson() {
  final object = this;
  if (object is UserMessage ||
      object is FileMessage ||
      object is AdminMessage ||
      object is ScheduledUserMessage) return object.toJson();
  throw UnrecognizedMessageTypeError();
}