MessageModel.fromJson constructor

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

Implementation

MessageModel.fromJson(Map<String, dynamic> json) {
  id = json["id"];
  time = json['time'];
  type = json['type'];
  value = json['value'];
  uniqueID = "$identityHashCode";

  if (type == "text") {
    value = removeHtmlTagFromString("$value");

    if ((value as String).contains("**id**")) {
      value = (value as String).replaceAll("**id**", "");
      lang = "id";
    } else

    //
    if ((value as String).contains("**en**")) {
      value = (value as String).replaceAll("**en**", "");
      lang = "en";
    }

    //
    else {
      lang = "id";
    }
  }
}