FlutterDiffViewerController class

Controls a FlutterDiffViewer widget's navigation, scrolling, and collapse state.

Provides programmatic access to change navigation, scrolling to specific lines, and expanding/collapsing unchanged sections.

final controller = FlutterDiffViewerController();

// Navigate changes
controller.nextChange();
controller.previousChange();
controller.goToChange(2);

// Collapse all unchanged sections
controller.collapseAll();

// Remember to dispose
controller.dispose();

Lifecycle note: If you create a FlutterDiffViewerController yourself, you are responsible for calling dispose. The FlutterDiffViewer widget will NOT dispose externally provided controllers.

Inheritance

Properties

changes List<DiffChange>
The ordered list of navigable change blocks in the current diff.
no setter
collapsedLineIndices Set<int>
Set of line indices that are currently in a collapsed state.
no setter
currentChange DiffChange?
The currently selected DiffChange, or null.
no setter
currentChangeIndex int
The 0-based index of the currently highlighted change.
no setter
error Object?
The error from the last failed diff calculation, or null.
no setter
hashCode int
The hash code for this object.
no setterinherited
hasListeners bool
Whether any listeners are currently registered.
no setterinherited
hasNextChange bool
Whether there is a next change to navigate to.
no setter
hasPreviousChange bool
Whether there is a previous change to navigate to.
no setter
leftScrollController ScrollController
The left panel scroll controller (side-by-side view).
no setter
primaryScrollController ScrollController
The primary vertical scroll controller (unified/stacked view).
no setter
result DiffResult?
The most recently calculated diff result.
no setter
rightScrollController ScrollController
The right panel scroll controller (side-by-side view).
no setter
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
state FlutterDiffViewerState
The current state of the diff viewer.
no setter
totalChanges int
The total number of navigable changes in the current diff.
no setter

Methods

addListener(VoidCallback listener) → void
Register a closure to be called when the object changes.
inherited
collapseAll() → void
Collapses all unchanged line sections.
dispose() → void
Discards any resources used by the object.
override
expandAll() → void
Expands all collapsed unchanged line sections.
expandSection(int lineIndex) → void
Expands the collapsed section containing the line at lineIndex.
goToChange(int index) → void
Navigates to the change at the given index.
isLineCollapsed(int lineIndex) bool
Returns true if the line at lineIndex is currently collapsed.
nextChange() → void
Navigates to the next change in the diff.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
notifyListeners() → void
Call all the registered listeners.
inherited
previousChange() → void
Navigates to the previous change in the diff.
removeListener(VoidCallback listener) → void
Remove a previously registered closure from the list of closures that are notified when the object changes.
inherited
scrollToLine(int lineIndex) → void
Scrolls the diff view to the line at lineIndex (0-based).
setError(Object error) → void
Transitions to the error state.
setLoading() → void
Transitions to the loading state.
setResult(DiffResult result) → void
Updates the controller with a new diff result.
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited