DiffView
A unified-diff viewer: additions, deletions, and hunk/file headers each styled, with an old | new line-number gutter.
See also: PatchReview to review a multi-file patch file by file.
Import: package:fleury/fleury.dart, or package:fleury/fleury_core.dart in browser code.
DiffView( diff: '''@@ -1,3 +1,3 @@ void main() {- print('hi');+ print('hello'); }''',)Details
Section titled “Details”Up and Down move the selected row; PageUp, PageDown, Home, and End jump;
clicking a row selects it. Ctrl+C copies the selected row, or its whole
hunk, header included, when copyOptions sets DiffViewCopyMode.hunk.
Constructors
Section titled “Constructors”DiffView()
Section titled “DiffView()”| Parameter | Type | Default | Description |
|---|---|---|---|
diff: | String | required | Unified-diff source parsed into document before mounting. |
controller: | DiffViewController? | — | External selection and visible-range controller. |
focusNode: | FocusNode? | — | Focus node used for keyboard navigation. |
autofocus: | bool | false | Whether the viewer should request focus when mounted. |
semanticLabel: | String | 'Diff' | Semantic label (the accessibility name; not rendered) for the diff viewer. |
maxLineLength: | int? | 1000 | Cuts each displayed row (not counting the line-number gutter) to this many characters, ending it with …; null never cuts. Copying still copies the whole row. |
showLineNumbers: | bool | true | Whether to show the old | new line-number gutter. Each row’s line numbers are tracked either way (DiffLine.oldLine, DiffLine.newLine). |
copySelection: | bool | true | Whether Ctrl+C (and the semantic copy action) copies the selected row, or its hunk if copyOptions says so. |
copyOptions: | DiffViewCopyOptions | const DiffViewCopyOptions() | Clipboard/export options for copied diff text. |
onCopy: | void Function(DiffViewCopyResult result)? | — | Called after a copy attempt completes. |
DiffView.document()
Section titled “DiffView.document()”Creates a viewer from an already parsed DiffDocument. maxLineLength
has no effect here: rows keep the length they were parsed with.
The document’s sanitized, optionally truncated rows are reused without parsing the unified-diff source again.
| Parameter | Type | Default | Description |
|---|---|---|---|
document: | DiffDocument | required | Parsed unified diff document to render. |
controller: | DiffViewController? | — | External selection and visible-range controller. |
focusNode: | FocusNode? | — | Focus node used for keyboard navigation. |
autofocus: | bool | false | Whether the viewer should request focus when mounted. |
semanticLabel: | String | 'Diff' | Semantic label (the accessibility name; not rendered) for the diff viewer. |
maxLineLength: | int? | 1000 | Cuts each displayed row (not counting the line-number gutter) to this many characters, ending it with …; null never cuts. Copying still copies the whole row. |
showLineNumbers: | bool | true | Whether to show the old | new line-number gutter. Each row’s line numbers are tracked either way (DiffLine.oldLine, DiffLine.newLine). |
copySelection: | bool | true | Whether Ctrl+C (and the semantic copy action) copies the selected row, or its hunk if copyOptions says so. |
copyOptions: | DiffViewCopyOptions | const DiffViewCopyOptions() | Clipboard/export options for copied diff text. |
onCopy: | void Function(DiffViewCopyResult result)? | — | Called after a copy attempt completes. |
Source
Section titled “Source”DiffView is defined in packages/fleury/lib/src/catalog/diff_view.dart.
Category: Agent surfaces · All widgets