fromJson static method

TargetResolution? fromJson(
  1. dynamic value
)

Returns a new TargetResolution instance and imports its values from value if it's a Map, null otherwise.

Implementation

// ignore: prefer_constructors_over_static_methods
static TargetResolution? fromJson(dynamic value) {
  if (value is Map) {
    final json = value.cast<String, dynamic>();

    // Ensure that the map contains the required keys.
    // Note 1: the values aren't checked for validity beyond being non-null.
    // Note 2: this code is stripped in release mode!
    assert(() {
      assert(json.containsKey(r'height'),
          'Required key "TargetResolution[height]" is missing from JSON.');
      assert(json[r'height'] != null,
          'Required key "TargetResolution[height]" has a null value in JSON.');
      assert(json.containsKey(r'width'),
          'Required key "TargetResolution[width]" is missing from JSON.');
      assert(json[r'width'] != null,
          'Required key "TargetResolution[width]" has a null value in JSON.');
      return true;
    }());

    return TargetResolution(
      bitrate: mapValueOfType<int>(json, r'bitrate'),
      height: mapValueOfType<int>(json, r'height')!,
      width: mapValueOfType<int>(json, r'width')!,
    );
  }
  return null;
}