CodeForgeWeb class

A highly customizable code editor widget for Flutter.

CodeForgeWeb 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 = CodeForgeWebController();

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

Constructors

CodeForgeWeb({Key? key, CodeForgeWebController? controller, UndoRedoController? undoController, Map<String, TextStyle>? editorTheme, Mode? language, List<Mode> extraLanguages = const [], TextStyle? ghostTextStyle, String? fileUri, String? fileUrl, String? initialText, FocusNode? focusNode, ScrollController? verticalScrollController, ScrollController? horizontalScrollController, TextStyle? textStyle, EdgeInsets? innerPadding, List<CustomCodeSnippet>? customCodeSnippets, bool readOnly = false, bool autoFocus = false, bool lineWrap = false, bool enableFolding = true, bool enableGuideLines = true, bool enableSuggestions = true, bool enableKeyboardSuggestions = true, TextInputType keyboardType = TextInputType.multiline, TextDirection textDirection = TextDirection.ltr, int? tabSize, bool useSpaceAsTab = false, bool enableGutter = true, bool enableGutterDivider = false, bool deleteFoldRangeOnDeletingFirstLine = false, CodeSelectionStyle? selectionStyle, GutterStyle? gutterStyle, SuggestionStyle? suggestionStyle, HoverDetailsStyle? hoverDetailsStyle, MatchHighlightStyle? matchHighlightStyle, PreferredSizeWidget finderBuilder(BuildContext context, FindController findController)?, FindController? findController})
Creates a CodeForgeWeb code editor widget.
const

Properties

autoFocus → bool
Whether to automatically focus the editor when mounted.
final
controller → CodeForgeWebController?
The controller for managing the editor's text content and selection.
final
customCodeSnippets → List<CustomCodeSnippet>?
A list of custom code snippets that appear in the suggestion popup.
final
deleteFoldRangeOnDeletingFirstLine → bool
If set to true, deleting the first line of a folded block will delete the entire folded region, else only the first line gets deleted and the rest of the block stays safe. Defauts to false.
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
enableKeyboardSuggestions → bool
Whether to show auto completions in the OS virtual keyboard.
final
enableSuggestions → bool
Whether to enable autocomplete suggestions.
final
extraLanguages → List<Mode>
Additional language modes registered in the same highlighter instance.
final
fileUri → String?
The file URI for LSP features (e.g., 'file:///workspace/main.dart').
final
fileUrl → String?
A raw file URL to load content from (e.g., GitHub raw URL).
final
findController → FindController?
The finder controller for managing search functionality.
final
finderBuilder → PreferredSizeWidget Function(BuildContext context, FindController findController)?
Builder for a custom Finder widget.
final
focusNode → FocusNode?
The focus node for managing keyboard focus.
final
ghostTextStyle → TextStyle?
The text style for ghost text (inline suggestions).
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
keyboardType → TextInputType
The type of the virtual keyboard that will used by the CodeForgeWeb.
final
language → Mode?
The programming language mode for syntax highlighting.
final
lineWrap → bool
Whether to wrap long lines.
final
matchHighlightStyle → MatchHighlightStyle?
Styling options for search match highlighting.
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
tabSize → int?
Custom tabSize for the editor. Defaults to 1 if using \t, or 2 if using space, by setting the useSpaceAsTab to true
final
textDirection → TextDirection
The text direction for the editor's content.
final
textStyle → TextStyle?
The base text style for the editor content.
final
undoController → UndoRedoController?
The controller for managing undo/redo operations.
final
useSpaceAsTab → bool
Use space instead of the \t character for tab key press.
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<CodeForgeWeb>
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