fromJsonString static method

ChannelData? fromJsonString(
  1. String jsonString
)

Creates a new instance from a json string.

Implementation

static ChannelData? fromJsonString(String jsonString) {
  dynamic json;
  try {
    json = jsonDecode(jsonString);
  } catch (e) {
    throw Exception(
      'Invalid channel_data json string "$jsonString", cannot decode json',
    );
  }

  if (json == null) return null;

  if (json is! Map) {
    throw Exception(
      "Invalid channel_data response data [$json], excepted Map got ${json.runtimeType}",
    );
  }

  return ChannelData.fromJson(json);
}