FlutterOutline.fromJson constructor

FlutterOutline.fromJson(
  1. JsonDecoder jsonDecoder,
  2. String jsonPath,
  3. Object? json
)

Implementation

factory FlutterOutline.fromJson(
    JsonDecoder jsonDecoder, String jsonPath, Object? json) {
  json ??= {};
  if (json is Map) {
    FlutterOutlineKind kind;
    if (json.containsKey('kind')) {
      kind = FlutterOutlineKind.fromJson(
          jsonDecoder, '$jsonPath.kind', json['kind']);
    } else {
      throw jsonDecoder.mismatch(jsonPath, 'kind');
    }
    int offset;
    if (json.containsKey('offset')) {
      offset = jsonDecoder.decodeInt('$jsonPath.offset', json['offset']);
    } else {
      throw jsonDecoder.mismatch(jsonPath, 'offset');
    }
    int length;
    if (json.containsKey('length')) {
      length = jsonDecoder.decodeInt('$jsonPath.length', json['length']);
    } else {
      throw jsonDecoder.mismatch(jsonPath, 'length');
    }
    int codeOffset;
    if (json.containsKey('codeOffset')) {
      codeOffset =
          jsonDecoder.decodeInt('$jsonPath.codeOffset', json['codeOffset']);
    } else {
      throw jsonDecoder.mismatch(jsonPath, 'codeOffset');
    }
    int codeLength;
    if (json.containsKey('codeLength')) {
      codeLength =
          jsonDecoder.decodeInt('$jsonPath.codeLength', json['codeLength']);
    } else {
      throw jsonDecoder.mismatch(jsonPath, 'codeLength');
    }
    String? label;
    if (json.containsKey('label')) {
      label = jsonDecoder.decodeString('$jsonPath.label', json['label']);
    }
    Element? dartElement;
    if (json.containsKey('dartElement')) {
      dartElement = Element.fromJson(
          jsonDecoder, '$jsonPath.dartElement', json['dartElement']);
    }
    List<FlutterOutlineAttribute>? attributes;
    if (json.containsKey('attributes')) {
      attributes = jsonDecoder.decodeList(
          '$jsonPath.attributes',
          json['attributes'],
          (String jsonPath, Object? json) =>
              FlutterOutlineAttribute.fromJson(jsonDecoder, jsonPath, json));
    }
    String? className;
    if (json.containsKey('className')) {
      className =
          jsonDecoder.decodeString('$jsonPath.className', json['className']);
    }
    String? parentAssociationLabel;
    if (json.containsKey('parentAssociationLabel')) {
      parentAssociationLabel = jsonDecoder.decodeString(
          '$jsonPath.parentAssociationLabel', json['parentAssociationLabel']);
    }
    String? variableName;
    if (json.containsKey('variableName')) {
      variableName = jsonDecoder.decodeString(
          '$jsonPath.variableName', json['variableName']);
    }
    List<FlutterOutline>? children;
    if (json.containsKey('children')) {
      children = jsonDecoder.decodeList(
          '$jsonPath.children',
          json['children'],
          (String jsonPath, Object? json) =>
              FlutterOutline.fromJson(jsonDecoder, jsonPath, json));
    }
    return FlutterOutline(kind, offset, length, codeOffset, codeLength,
        label: label,
        dartElement: dartElement,
        attributes: attributes,
        className: className,
        parentAssociationLabel: parentAssociationLabel,
        variableName: variableName,
        children: children);
  } else {
    throw jsonDecoder.mismatch(jsonPath, 'FlutterOutline', json);
  }
}