UnifiedDiff.fromPatch constructor

UnifiedDiff.fromPatch(
  1. Patch<String> patch, {
  2. required UnifiedDiffHeader header,
  3. int context = 3,
  4. UnifiedDiffHunkHeaderConfig hunkHeaderConfig = const UnifiedDiffHunkHeaderConfig(),
})

Create a UnifiedDiff from the specified patch using the information from the header.

By default context is 3, resulting in 3 lines of code included on either side of a change for contextual purposes.

To configure the header format for each hunk, pass in a custom UnifiedDiffHunkHeaderConfig.

Implementation

factory UnifiedDiff.fromPatch(
  final Patch<String> patch, {
  required final UnifiedDiffHeader header,
  final int context = 3,
  final UnifiedDiffHunkHeaderConfig hunkHeaderConfig =
      const UnifiedDiffHunkHeaderConfig(),
}) {
  final hunks = _calculateHunksFromPatch(patch, hunkHeaderConfig, context);

  return UnifiedDiff._(header, hunks);
}