CodeForge class

A highly customizable code editor widget for Flutter.

CodeForge provides a feature-rich code editing experience with support for:

  • Syntax highlighting for multiple languages
  • Code folding
  • Line numbers and gutter
  • Auto-indentation and bracket matching
  • LSP (Language Server Protocol) integration
  • AI code completion
  • Undo/redo functionality
  • Search highlighting

Example:

final controller = CodeForgeController();

CodeForge(
  controller: controller,
  language: langDart,
  enableFolding: true,
  enableGutter: true,
  textStyle: TextStyle(
    fontFamily: 'JetBrains Mono',
    fontSize: 14,
  ),
)
Inheritance

Constructors

CodeForge({Key? key, CodeForgeController? controller, UndoRedoController? undoController, Map<String, TextStyle>? editorTheme, Mode? language, AiCompletion? aiCompletion, TextStyle? aiCompletionTextStyle, LspConfig? lspConfig, String? filePath, String? initialText, FocusNode? focusNode, ScrollController? verticalScrollController, ScrollController? horizontalScrollController, TextStyle? textStyle, EdgeInsets? innerPadding, bool readOnly = false, bool autoFocus = false, bool lineWrap = false, bool enableFolding = true, bool enableGuideLines = true, bool enableSuggestions = true, bool enableGutter = true, bool enableGutterDivider = false, CodeSelectionStyle? selectionStyle, GutterStyle? gutterStyle, SuggestionStyle? suggestionStyle, HoverDetailsStyle? hoverDetailsStyle})
Creates a CodeForge code editor widget.
const

Properties

aiCompletion AiCompletion?
Configuration for AI-powered code completion.
final
aiCompletionTextStyle TextStyle?
The text style for AI completion ghost text.
final
autoFocus bool
Whether to automatically focus the editor when mounted.
final
controller CodeForgeController?
The controller for managing the editor's text content and selection.
final
editorTheme Map<String, TextStyle>?
The syntax highlighting theme as a map of token types to TextStyle.
final
enableFolding bool
Whether to enable code folding functionality.
final
enableGuideLines bool
Whether to show indentation guide lines.
final
enableGutter bool
Whether to show the gutter with line numbers.
final
enableGutterDivider bool
Whether to show a divider line between gutter and content.
final
enableSuggestions bool
Whether to enable autocomplete suggestions.
final
filePath String?
The file path for LSP features.
final
focusNode FocusNode?
The focus node for managing keyboard focus.
final
gutterStyle GutterStyle?
Styling options for the gutter (line numbers and fold icons).
final
hashCode int
The hash code for this object.
no setterinherited
horizontalScrollController ScrollController?
Custom scroll controller for horizontal scrolling.
final
hoverDetailsStyle HoverDetailsStyle?
Styling options for hover documentation popup.
final
initialText String?
Initial text content for the editor.
final
innerPadding EdgeInsets?
Padding inside the editor content area.
final
key Key?
Controls how one widget replaces another widget in the tree.
finalinherited
language → Mode?
The programming language mode for syntax highlighting.
final
lineWrap bool
Whether to wrap long lines.
final
lspConfig LspConfig?
Configuration for Language Server Protocol integration.
final
readOnly bool
Whether the editor is in read-only mode.
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
selectionStyle CodeSelectionStyle?
Styling options for text selection and cursor.
final
suggestionStyle SuggestionStyle?
Styling options for the autocomplete suggestion popup.
final
textStyle TextStyle?
The base text style for the editor content.
final
undoController UndoRedoController?
The controller for managing undo/redo operations.
final
verticalScrollController ScrollController?
Custom scroll controller for vertical scrolling.
final

Methods

createElement() StatefulElement
Creates a StatefulElement to manage this widget's location in the tree.
inherited
createState() State<CodeForge>
Creates the mutable state for this widget at a given location in the tree.
override
debugDescribeChildren() List<DiagnosticsNode>
Returns a list of DiagnosticsNode objects describing this node's children.
inherited
debugFillProperties(DiagnosticPropertiesBuilder properties) → void
Add additional properties associated with the node.
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toDiagnosticsNode({String? name, DiagnosticsTreeStyle? style}) DiagnosticsNode
Returns a debug representation of the object that is used by debugging tools and by DiagnosticsNode.toStringDeep.
inherited
toString({DiagnosticLevel minLevel = DiagnosticLevel.info}) String
A string representation of this object.
inherited
toStringDeep({String prefixLineOne = '', String? prefixOtherLines, DiagnosticLevel minLevel = DiagnosticLevel.debug, int wrapWidth = 65}) String
Returns a string representation of this node and its descendants.
inherited
toStringShallow({String joiner = ', ', DiagnosticLevel minLevel = DiagnosticLevel.debug}) String
Returns a one-line detailed description of the object.
inherited
toStringShort() String
A short, textual description of this widget.
inherited

Operators

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