GhostText class

Represents ghost text (inline suggestion) displayed in the editor.

Ghost text appears as semi-transparent text at the cursor position, typically used for AI code completion suggestions.

When shouldPersist is false (default), the ghost text will be:

  • Cleared when the cursor moves or text changes don't match
  • Accepted (inserted) when Tab or Right Arrow is pressed

When shouldPersist is true, the ghost text will only be cleared by explicitly calling CodeForgeController.clearGhostText.

Example:

controller.setGhostText(GhostText(
  line: 10,
  column: 15,
  text: 'print("Hello, World!");',
  style: TextStyle(
    color: Colors.grey.withOpacity(0.5),
    fontStyle: FontStyle.italic,
  ),
));

Constructors

GhostText({required int line, required int column, required String text, TextStyle? style, bool shouldPersist = false})
Creates a ghost text decoration.
const

Properties

column int
The column where the ghost text starts (0-based)
final
hashCode int
The hash code for this object.
no setterinherited
line int
The line where the ghost text starts (0-based)
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
shouldPersist bool
Whether the ghost text should persist until explicitly cleared.
final
style TextStyle?
Text style for the ghost text
final
text String
The ghost text content (can be multi-line with \n)
final

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
inherited

Operators

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