copyWith method

FileDiff copyWith({
  1. List<DiffHunk>? hunks,
  2. List<String>? oldLines,
  3. List<String>? newLines,
  4. String? oldText,
  5. String? newText,
  6. int? revision,
  7. String? patchLineEnding,
  8. String? language,
  9. String? identity,
})

Replaces computed data while preserving source metadata and identity. Changing a known full source invalidates that side's Git object ID.

Implementation

FileDiff copyWith({
  List<DiffHunk>? hunks,
  List<String>? oldLines,
  List<String>? newLines,
  String? oldText,
  String? newText,
  int? revision,
  String? patchLineEnding,
  String? language,
  String? identity,
}) => FileDiff(
  oldPath: oldPath,
  newPath: newPath,
  kind: kind,
  hunks: hunks ?? this.hunks,
  isBinary: isBinary,
  oldLines: oldLines ?? this.oldLines,
  newLines: newLines ?? this.newLines,
  oldText: oldText ?? this.oldText,
  newText: newText ?? this.newText,
  identity: identity ?? this.identity,
  revision: revision ?? this.revision,
  language: language ?? this.language,
  oldObjectId:
      oldText != null && this.oldText != null && oldText != this.oldText
      ? null
      : oldObjectId,
  newObjectId:
      newText != null && this.newText != null && newText != this.newText
      ? null
      : newObjectId,
  oldMode: oldMode,
  newMode: newMode,
  patchLineEnding: patchLineEnding ?? this.patchLineEnding,
);