fromJson static method

IssueView? fromJson(
  1. dynamic value
)

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

Implementation

// ignore: prefer_constructors_over_static_methods
static IssueView? 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(() {
      requiredKeys.forEach((key) {
        assert(json.containsKey(key), 'Required key "IssueView[$key]" is missing from JSON.');
        assert(json[key] != null, 'Required key "IssueView[$key]" has a null value in JSON.');
      });
      return true;
    }());

    return IssueView(
      assignee: mapValueOfType<String>(json, r'assignee'),
      createdAt: mapValueOfType<int>(json, r'createdAt'),
      description: mapValueOfType<String>(json, r'description'),
      dueAt: mapValueOfType<int>(json, r'dueAt'),
      extRef: mapValueOfType<String>(json, r'extRef'),
      id: mapValueOfType<String>(json, r'id'),
      identifier: mapValueOfType<String>(json, r'identifier'),
      kind: mapValueOfType<String>(json, r'kind'),
      labels: json[r'labels'] is Iterable
          ? (json[r'labels'] as Iterable).cast<String>().toList(growable: false)
          : const [],
      number: mapValueOfType<int>(json, r'number'),
      priority: mapValueOfType<String>(json, r'priority'),
      projectKey: mapValueOfType<String>(json, r'projectKey'),
      repo: mapValueOfType<String>(json, r'repo'),
      source_: mapValueOfType<String>(json, r'source'),
      startAt: mapValueOfType<int>(json, r'startAt'),
      status: mapValueOfType<String>(json, r'status'),
      title: mapValueOfType<String>(json, r'title'),
      updatedAt: mapValueOfType<int>(json, r'updatedAt'),
    );
  }
  return null;
}