CustomCodeSnippet class

Represents a single custom code snippet that appears in the editor's suggestion list alongside LSP completions.

label is the text displayed in the suggestion popup (e.g. "if-else").

value is the actual code that gets inserted when the snippet is accepted.

cursorLocations is an ordered set of character offsets within value that determine where cursors are placed after insertion:

  • The first value becomes the primary cursor position.
  • Every subsequent value becomes a secondary (multi) cursor.

Offsets are relative to the start of the inserted value text.

Example:

// Inserts an if-else block and places the primary cursor inside the
// if-branch and a secondary cursor inside the else-branch.
CustomCodeSnippet(
  label: 'if-else',
  value: 'if (condition) {\n  \n} else {\n  \n}',
  cursorLocations: {18, 32},
)

Constructors

CustomCodeSnippet({required String label, required String value, required Set<int> cursorLocations})
Creates a custom code snippet.

Properties

cursorLocations Set<int>
Cursor positions (offsets within value) after insertion.
final
hashCode int
The hash code for this object.
no setterinherited
label String
The label shown in the suggestion popup.
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
value String
The code template inserted into the editor when the snippet is accepted.
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