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
-
- Object
- DiagnosticableTree
- Widget
- StatefulWidget
- CodeForge
Constructors
-
CodeForge({Key? key, CodeForgeController? controller, UndoRedoController? undoController, Map<
String, TextStyle> ? editorTheme, Mode? language, String? filePath, String? initialText, FocusNode? focusNode, ScrollController? verticalScrollController, ScrollController? horizontalScrollController, ScrollPhysics verticalScrollPhysics = const ClampingScrollPhysics(), TextStyle? textStyle, EdgeInsets? innerPadding, CodeForgeKeyboardShortcuts keyboardShotcuts = const CodeForgeKeyboardShortcuts(), List<CustomCodeSnippet> ? customCodeSnippets, bool readOnly = false, bool autoFocus = false, bool lineWrap = false, bool enableFolding = true, bool enableGuideLines = true, bool enableLocalSuggestions = false, 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, GutterBuilder? gutterBuilder, ScrollbarDecoration? scrollbarDecoration, TextStyle? ghostTextStyle, SuggestionStyle? suggestionStyle, HoverDetailsStyle? hoverDetailsStyle, MatchHighlightStyle? matchHighlightStyle, List<Mode> extraLanguages = const [], PreferredSizeWidget finderBuilder(BuildContext context, FindController findController)?, FindController? findController}) -
Creates a CodeForge code editor widget.
const
Properties
- 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
-
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
- enableLocalSuggestions → bool
-
Whether to enable local and non LSP autocomplete suggestions.
To control LSP suggestions, use the
capabilitiesfield of the LspConfig.falseby default because, this may cause delay or jitter in large files.final -
extraLanguages
→ List<
Mode> -
Additional language modes registered in the same highlighter instance.
final
- filePath → String?
-
The file path for LSP features.
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
- gutterBuilder → GutterBuilder?
-
Can be used to build gutter with custom content instead of line numbers.
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
- keyboardShotcuts → CodeForgeKeyboardShortcuts
-
Keyboard shortcuts used by the CodeForge editor.
Most of the keyboard shortcuts, except the core operations like cut, copy, paste, select all, undo, redo can be modified by editing the hardcoded shortcuts defined in theCodeForgeKeyboardShotcutsclass.
eg:final - keyboardType → TextInputType
-
The type of the virtual keyboard that will used by the CodeForge.
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
- scrollbarDecoration → ScrollbarDecoration?
-
Customize the scroll appearance.
Currently included vertical scrollbar only.
final
- 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 totruefinal - 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
\tcharacter for tab key press.final - verticalScrollController → ScrollController?
-
Custom scroll controller for vertical scrolling.
final
- verticalScrollPhysics → ScrollPhysics
-
The scroll physics that can be used to modify the vertical scroll behaviour of the editor.
Defaults to ClampingScrollPhysics.
The horizontal scroll physics cannot be modified because CodeForge internally uses a custom scroll physics for RTL support.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