fromJson static method

ServerSentEvent fromJson(
  1. String json
)

Implementation

static ServerSentEvent fromJson(String json) {
  try {
    Map map = jsonDecode(json);
    return ServerSentEvent()
      ..elementType = map['elementType'].toString()
      ..sessionLogId = map['sessionLogId'].toString()
      ..result = map['result']?.toString() ?? ''
      ..extra = jsonEncode(map['extra'])
      ..isHistory = map["isHistory"] ?? false;
  } catch (e) {
    return ServerSentEvent()
      ..elementType = ''
      ..sessionLogId = ''
      ..extra = null
      ..result = '';
  }
}