highlight
0.7.0, released 6 years ago by an unverified publisher
Dart library that parses source code into syntax‑highlighted HTML
WASM-ready
What it does
The package tokenises source code and produces an HTML string with CSS classes for each token. It supports many languages and themes, and can be used in any Dart or Flutter project.
AI-written summary of version 0.7.0, based on the package's README and metadata. Report an inaccuracy
Use it when
- You need syntax highlighting for code snippets in a web or desktop app
- You want a pure Dart solution without Flutter dependencies
- You need to generate highlighted code for documentation or static sites
Skip it when
- You need a Flutter widget that renders highlighted code directly
- You require real‑time syntax highlighting in a text editor
Strengths
- Null‑safe API
- Supports dozens of languages out of the box
- Provides a core module for manual language registration
- Produces clean HTML output
Weaknesses
- No built‑in Flutter widget
- Only outputs HTML, not Flutter widgets
- Limited to syntax highlighting, no editor features
Setup
- Kind
- Pure Dart
- Effort
- Low
- Code generation
- No
- Direct dependencies
- 1
import 'package:highlight/highlight.dart' show highlight;
void main() {
var source = '''main() {
print("Hello, World!");
}''';
var result = highlight.parse(source, language: 'dart');
var html = result.toHtml();
print(html);
}Alternatives
Packages that do the same job and could replace highlight.
Works with
Packages commonly used together with highlight: ones it builds on, ones built on it, and its own family.
- flutter_highlightBuilt on highlightA Flutter widget that highlights source code with many languages and themes.
- flutter_code_editorBuilt on highlightA customizable code field widget supporting syntax highlighting and code folding.
- code_text_fieldBuilt on highlightA customizable code text field supporting syntax highlighting and scrolling.
- flutter_quill_to_pdfBuilt on highlightCreate PDF'S using deltas from Quill, with configurable attributes, fonts, and custom pdf widgets
- markdown_widgetBuilt on highlightA simple and easy-to-use markdown rendering component for Flutter.
- flutter_smooth_markdownBuilt on highlightHigh-performance markdown renderer and editor with syntax highlighting, LaTeX, tables, SVG, Mermaid, and real-time streaming.
- hyper_renderBuilt on highlightThe only Flutter HTML/Markdown renderer with CSS float layout, crash-free text selection at any document size, CJK Ruby typography, and AI/LLM token streaming.