Skip to content
pubscout

shiki_flutter

1.1.0, released 4 months ago by birju.dev

TextMate-grammar based syntax highlighter for Flutter ported from Shiki.

WASM-ready
$ flutter pub add shiki_flutter
Source repository

What it does

Tokenizes source code with real VS Code TextMate grammars and Shiki themes and renders it as styled TextSpans or through dedicated widgets. Supports ~250 languages and 75 themes, running on a background isolate or Web Worker.

AI-written summary of version 1.1.0, based on the package's README and metadata. Report an inaccuracy

Use it when

  • You need accurate syntax highlighting that matches VS Code colors.
  • You want to display formatted source code inside Flutter widgets.
  • You need a TextField controller that highlights syntax as users type.

Skip it when

  • You are building a full-featured code editor with advanced IDE features beyond syntax-highlighted text input.
  • You want to avoid bundled language grammars and dynamically fetch everything from remote servers without custom loading.

Strengths

  • Golden-tested token output matching VS Code exactly.
  • Supports off-main-thread background isolate highlighting to keep UI smooth.
  • Includes a drop-in syntax-highlighting TextEditingController.
  • Runs on every platform Flutter supports without mandatory native dependencies.

Weaknesses

  • Web async highlighting requires setting up a browser Web Worker.
  • Very large files still incur Flutter paragraph layout costs.

Setup

Kind
Flutter widgets
Effort
Low
Code generation
No
Direct dependencies
4

Pure Dart by default with no native build steps required, though an optional Web Worker can be installed for web async support.

ShikiCodeView(
  code: "void main() => print('Hello');",
  lang: CodeLanguages.dart,
  textStyle: const TextStyle(fontFamily: 'FiraCode', fontSize: 14),
)

Alternatives

Packages that do the same job and could replace shiki_flutter.

Works with

Packages commonly used together with shiki_flutter: ones it builds on, ones built on it, and its own family.