copyWith method
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,
);