EditFormatParams.fromJson constructor

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

Implementation

factory EditFormatParams.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 selectionOffset;
    if (json.containsKey('selectionOffset')) {
      selectionOffset = jsonDecoder.decodeInt(
          '$jsonPath.selectionOffset', json['selectionOffset']);
    } else {
      throw jsonDecoder.mismatch(jsonPath, 'selectionOffset');
    }
    int selectionLength;
    if (json.containsKey('selectionLength')) {
      selectionLength = jsonDecoder.decodeInt(
          '$jsonPath.selectionLength', json['selectionLength']);
    } else {
      throw jsonDecoder.mismatch(jsonPath, 'selectionLength');
    }
    int? lineLength;
    if (json.containsKey('lineLength')) {
      lineLength =
          jsonDecoder.decodeInt('$jsonPath.lineLength', json['lineLength']);
    }
    return EditFormatParams(file, selectionOffset, selectionLength,
        lineLength: lineLength);
  } else {
    throw jsonDecoder.mismatch(jsonPath, 'edit.format params', json);
  }
}