shiki_flutter
1.1.0, released 4 months ago by birju.dev
TextMate-grammar based syntax highlighter for Flutter ported from Shiki.
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.
- code_editor
A Flutter code editor widget with syntax highlighting, custom themes, and file navigation.
82Compare - val_highlight_flutter
Flutter widgets for displaying and editing syntax-highlighted code.
80Compare - re_editor
A lightweight text and code editor widget for Flutter with syntax highlighting and folding.
80Compare - flutter_highlight
A Flutter widget that highlights source code with many languages and themes.
50Compare
Works with
Packages commonly used together with shiki_flutter: ones it builds on, ones built on it, and its own family.