Skip to content
This repository was archived by the owner on Dec 11, 2025. It is now read-only.
This repository was archived by the owner on Dec 11, 2025. It is now read-only.

Add programmatic API to fold and unfold all code regions #12

Open

Description

@jpdup

Currently, CodeCrafterController supports code folding through callbacks like setFoldAtCallback, but there is no public API to programmatically trigger folding or unfolding of all foldable regions.

This limitation makes it difficult to:

  • Implement "Collapse All" / "Expand All" buttons in an IDE-style UI.
  • Restore user fold states after reopening a file.
  • Provide shortcuts or automated folding behavior.

—
Feature Request
Please add public methods (or similar) to CodeCrafterController, e.g.:
dart
controller.collapseAll();
controller.expandAll();
controller.toggleFoldAtLine(int lineIndex);

Or a method such as setFoldStateForAll(bool folded).
These should update internal folding state and call refresh() to re-render.

Motivation / Use Case
I’m building a custom Flutter code editor and need UI buttons or keyboard shortcuts for “Collapse All / Expand All.”

Current Workaround
Limitation: only workaround is to redefine foldAt callback and call controller.refresh(), which isn’t ergonomic for UI actions.

—
Suggested Implementation
• Add collapseAll()

Activity

  1. heckmon commented on Oct 5, 2025

    @heckmon
    Owner

    You can programmatically fold any foldable lines using controller.foldAt(line_numer).
    However I cannot update anything right now because I'm too busy with my college exams.

    Also I'm building a new code editor called flutter_code_forge from scratch using RenderBox by drawing pixels in canvas instead of extending TextEditingController. It's a complete alternative to this package . Because Flutter's built in TextField lags for large text files with 2000+ lines of code.
    So I will add these features in flutter_code_forge.

  2. heckmon commented on Dec 11, 2025

    @heckmon
    Owner

    @jpdup Hello, finally, I published the new package code_forge with features like foldAll, unfoldAll, toggleFold, etc.
    Have a look: https://pub.dev/packages/code_forge

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions