GitDiffViewer class

A widget for viewing git diffs with syntax highlighting and scrolling.

Wraps GitDiffModel (a TUI bubble) in the widget system. Supports unified diff format with colored additions/deletions, line numbers, and keyboard/mouse scrolling.

Example

class MyApp extends StatefulWidget {
  @override
  State createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  final _controller = GitDiffController();

  @override
  void initState() {
    super.initState();
    _controller.setDiff(rawDiffString);
  }

  @override
  Widget build(BuildContext context) {
    return GitDiffViewer(
      diff: rawDiffString,
      width: 80,
      height: 24,
      controller: _controller,
    );
  }
}
Inheritance

Constructors

GitDiffViewer({required String diff, int? width, int? height, bool showLineNumbers = true, bool wrapLines = true, bool zeroPadLineNumbers = false, DiffViewMode? viewMode, DiffStyles? styles, GitDiffController? controller, bool handleKeys = true, bool scrollable = true, bool fitContentHeight = false, Key? key})
Creates a git diff viewer widget.

Properties

children List<Widget>
Child widgets that receive forwarded messages.
no setterinherited
controller GitDiffController?
Optional controller for external access to the diff model.
final
debugRenderObjectPassthrough bool
Whether this widget is intentionally transparent to render-object layouts.
no setterinherited
diff String
The raw unified diff text to display.
final
fitContentHeight bool
Whether to auto-size height to rendered content line count.
final
focusable bool
Whether this widget can receive keyboard focus.
no setterinherited
handleKeys bool
Whether to handle keyboard input for scrolling.
final
hashCode int
The hash code for this object.
no setterinherited
height int?
Height of the viewer in rows. Defaults to available height.
final
id String
Unique identifier for this widget.
no setterinherited
key Key?
Key for preserving widget identity.
finalinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
scrollable bool
Whether this viewer should process scrolling input.
final
showLineNumbers bool
Whether to show line numbers in the gutter.
final
styles DiffStyles?
Custom diff styling.
final
theme Theme
Access the current theme.
no setterinherited
viewMode DiffViewMode?
Display mode (unified, side-by-side, or pretty).
final
width int?
Width of the viewer in columns. Defaults to available width.
final
wrapLines bool
Whether to wrap long lines that exceed the viewport width.
final
zeroPadLineNumbers bool
Whether to zero-pad line numbers (e.g. 0001) instead of space-padding (e.g. 1).
final

Methods

buildCachedView<T>(T builder(), Object? cacheKey) → T
Returns a cached view if the cache key matches.
inherited
createState() State<StatefulWidget>
Creates the mutable State associated with this widget.
override
handleInit() Cmd?
Override this instead of init for widget-specific initialization.
inherited
handleIntercept(Msg msg) → (Widget, Cmd?)
Override this to handle messages before they reach children.
inherited
handleUpdate(Msg msg) → (Widget, Cmd?)
Override this to handle messages specific to this widget.
inherited
init() Cmd?
Called once when the widget is first mounted.
inherited
invalidateCachedView() → void
Clears any cached view for this widget.
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
inherited
update(Msg msg) → (Model, Cmd?)
Handles messages by forwarding to children then calling handleUpdate.
inherited
view() Object
Renders the widget to a string or View.
inherited

Operators

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