EditListPostfixCompletionTemplatesResult.fromJson constructor

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

Implementation

factory EditListPostfixCompletionTemplatesResult.fromJson(
    JsonDecoder jsonDecoder, String jsonPath, Object? json) {
  json ??= {};
  if (json is Map) {
    List<PostfixTemplateDescriptor> templates;
    if (json.containsKey('templates')) {
      templates = jsonDecoder.decodeList(
          '$jsonPath.templates',
          json['templates'],
          (String jsonPath, Object? json) =>
              PostfixTemplateDescriptor.fromJson(
                  jsonDecoder, jsonPath, json));
    } else {
      throw jsonDecoder.mismatch(jsonPath, 'templates');
    }
    return EditListPostfixCompletionTemplatesResult(templates);
  } else {
    throw jsonDecoder.mismatch(
        jsonPath, 'edit.listPostfixCompletionTemplates result', json);
  }
}