CompletionGetSuggestions2Result.fromJson constructor

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

Implementation

factory CompletionGetSuggestions2Result.fromJson(
    JsonDecoder jsonDecoder, String jsonPath, Object? json) {
  json ??= {};
  if (json is Map) {
    int replacementOffset;
    if (json.containsKey('replacementOffset')) {
      replacementOffset = jsonDecoder.decodeInt(
          '$jsonPath.replacementOffset', json['replacementOffset']);
    } else {
      throw jsonDecoder.mismatch(jsonPath, 'replacementOffset');
    }
    int replacementLength;
    if (json.containsKey('replacementLength')) {
      replacementLength = jsonDecoder.decodeInt(
          '$jsonPath.replacementLength', json['replacementLength']);
    } else {
      throw jsonDecoder.mismatch(jsonPath, 'replacementLength');
    }
    List<CompletionSuggestion> suggestions;
    if (json.containsKey('suggestions')) {
      suggestions = jsonDecoder.decodeList(
          '$jsonPath.suggestions',
          json['suggestions'],
          (String jsonPath, Object? json) =>
              CompletionSuggestion.fromJson(jsonDecoder, jsonPath, json));
    } else {
      throw jsonDecoder.mismatch(jsonPath, 'suggestions');
    }
    bool isIncomplete;
    if (json.containsKey('isIncomplete')) {
      isIncomplete = jsonDecoder.decodeBool(
          '$jsonPath.isIncomplete', json['isIncomplete']);
    } else {
      throw jsonDecoder.mismatch(jsonPath, 'isIncomplete');
    }
    return CompletionGetSuggestions2Result(
        replacementOffset, replacementLength, suggestions, isIncomplete);
  } else {
    throw jsonDecoder.mismatch(
        jsonPath, 'completion.getSuggestions2 result', json);
  }
}