Skip to content
pubscout

highlight

0.7.0, released 6 years ago by an unverified publisher

Dart library that parses source code into syntax‑highlighted HTML

WASM-ready
$ flutter pub add highlight
Source repository

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.

  • extension

    A collection of Dart extensions for strings, dates, numbers, iterables and more.

Works with

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