toggleFold method

void toggleFold(
  1. int lineNumber
)

Toggles the fold state at the specified line number.

lineNumber is zero-indexed (0 for the first line). If the line is at the start of a fold region, it will be toggled.

Throws StateError if:

  • Folding is not enabled on the editor
  • The editor has not been initialized
  • No fold range exists at the specified line

Example:

controller.toggleFold(5); // Toggle fold at line 6

Implementation

void toggleFold(int lineNumber) {
  if (_toggleFoldCallback == null) {
    throw StateError('Folding is not enabled or editor is not initialized');
  }
  _toggleFoldCallback!(lineNumber);
}