lapce_editor_flutter 0.1.1 copy "lapce_editor_flutter: ^0.1.1" to clipboard
lapce_editor_flutter: ^0.1.1 copied to clipboard

Reusable Flutter code editor backed by the pure-Dart Lapce editor core.

lapce_editor_flutter #

Reusable Flutter code-editor widget backed by lapce_editor_core. It includes viewport-local rendering, scrolling, multiple selections and carets, desktop shortcuts, clipboard and delta IME input, wrapping, phantom text, decorations, whitespace/indent guides, and an optional gutter.

Syntax parsing is supplied by the separate tree_sitter_dart package. TreeSitterSyntaxHighlighter is this package's Flutter adapter: it loads the bundled grammar/query assets, performs incremental parsing, and feeds capture styles into the viewport. The runtime does not use JavaScript, WebAssembly, or native FFI. Additional languages can implement TreeSitterGrammar and provide their capture query.

Basic use #

import 'package:flutter/material.dart';
import 'package:lapce_editor_flutter/lapce_editor_flutter.dart';

final editor = TextEditor(
  text: 'void main() {}\n',
  autofocus: true,
  placeholder: 'Start typing…',
  onUpdate: (text, revision, deltas) {
    // Persist text or transform host-owned anchors with deltas.
  },
);

TextEditor is the high-level fluent facade. Configuration methods return a new widget:

final configured = TextEditor(text: source)
    .readOnly(false)
    .editorStyle(const LapceEditorTheme(
      showIndentGuides: true,
      wrapMethod: WrapMethod.editorWidth(),
    ))
    .preCommand((command) => false);

Use LapceEditor directly when the host owns a LapceEditorController. A controller can be shared by multiple views; dispose it only from the owner that created it.

final controller = LapceEditorController(text: source);

Row(children: [
  Expanded(child: LapceEditor(controller: controller)),
  Expanded(child: LapceEditor(controller: controller)),
]);

Use TextDocument with useDoc/shareDoc when command hooks, placeholders, document-level styling, or document update callbacks are needed. Supply EditorDecorationProvider and EditorPhantomTextProvider implementations for diagnostics, inlay hints, or other host-owned visual data. Supply an EditorSyntaxHighlightProvider, or use the included TreeSitterSyntaxHighlighter, for syntax spans.

The widget uses a bounded input mirror: only the primary caret participates in active IME composition, while committed text is replicated to secondary carets in one edit group. Hosts should still run the manual dead-key and CJK smoke matrix on every desktop platform included in a release.

0
likes
150
points
160
downloads

Documentation

API reference

Publisher

verified publishermeshagent.com

Weekly Downloads

Reusable Flutter code editor backed by the pure-Dart Lapce editor core.

Repository (GitHub)
View/report issues

License

Apache-2.0 (license)

Dependencies

flutter, lapce_editor_core, tree_sitter_dart, web

More

Packages that depend on lapce_editor_flutter