getObject static method

SIQMessage? getObject(
  1. Map? map
)

internal method to convert the map to the object

Implementation

static SIQMessage? getObject(Map? map) {
  if (map != null) {
    String? sender = map["sender"]?.toString();
    // String? senderId = map["sender_id"];
    String? text = map["text"]?.toString();
    // String? type = map["type"];
    double? _time = map["time"] as double?;
    // bool? sentByVisitor = map["sent_by_visitor"] ?? false;
    bool? isRead = map["is_read"] as bool?;
    // Status? status = map["status"];
    Map? fileMap = map["file"] as Map?;
    String? name = fileMap?["name"] as String?;
    String? comment = fileMap?["comment"] as String?;
    String? contentType = fileMap?["content_type"] as String?;
    int size = fileMap?["size"] as int? ?? 0;
    File? file = File(name, comment, contentType, size);
    DateTime? time;
    if (_time != null) {
      time = _convertDoubleToDateTime(_time);
    }
    SIQMessage message = SIQMessage(text, sender, time, isRead, file);
    return message;
  } else {
    return null;
  }
}