layoutDiff function

List<DiffRow> layoutDiff(
  1. List<FileDiff> files, {
  2. DiffMode mode = DiffMode.unified,
  3. Set<int> collapsed = const {},
  4. Set<DiffGapId> expanded = const {},
})

Lays out files as the rows a diff view shows, top to bottom.

Each file with a path starts with a DiffFileHeaderRow, and files whose index is in collapsed stop there. A file without a path has no header to expand it again, so it is never collapsed. A file without hunks gets a DiffNoticeRow. When a file has its full texts, as from diffTexts, the unchanged lines around hunks become DiffGapRows, or context lines when their DiffGapId is in expanded. The hunk header after an expanded gap is left out, since the code then runs on without a break.

collapsed and expanded refer to files by index, so start them afresh when files changes. The result is empty only when files is.

Implementation

List<DiffRow> layoutDiff(
  List<FileDiff> files, {
  DiffMode mode = DiffMode.unified,
  Set<int> collapsed = const {},
  Set<DiffGapId> expanded = const {},
}) => DiffLayout(files, mode: mode, collapsed: collapsed, expanded: expanded);