CompletionGetSuggestionDetails2Params.fromJson constructor

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

Implementation

factory CompletionGetSuggestionDetails2Params.fromJson(
    JsonDecoder jsonDecoder, String jsonPath, Object? json) {
  json ??= {};
  if (json is Map) {
    String file;
    if (json.containsKey('file')) {
      file = jsonDecoder.decodeString('$jsonPath.file', json['file']);
    } else {
      throw jsonDecoder.mismatch(jsonPath, 'file');
    }
    int offset;
    if (json.containsKey('offset')) {
      offset = jsonDecoder.decodeInt('$jsonPath.offset', json['offset']);
    } else {
      throw jsonDecoder.mismatch(jsonPath, 'offset');
    }
    String completion;
    if (json.containsKey('completion')) {
      completion = jsonDecoder.decodeString(
          '$jsonPath.completion', json['completion']);
    } else {
      throw jsonDecoder.mismatch(jsonPath, 'completion');
    }
    String libraryUri;
    if (json.containsKey('libraryUri')) {
      libraryUri = jsonDecoder.decodeString(
          '$jsonPath.libraryUri', json['libraryUri']);
    } else {
      throw jsonDecoder.mismatch(jsonPath, 'libraryUri');
    }
    return CompletionGetSuggestionDetails2Params(
        file, offset, completion, libraryUri);
  } else {
    throw jsonDecoder.mismatch(
        jsonPath, 'completion.getSuggestionDetails2 params', json);
  }
}