Open source · Dart & Flutter · v0.1.2

Code that reads, in pure Dart.

A syntax highlighter for 55 languages that runs anywhere Dart does — and Flutter widgets to show code, and to edit it, with the colours following every keystroke.

$flutter pub add val_highlight_flutter val_highlight material_ui
Read the docs pub.dev
fizzbuzz.pyauto
rendering…val_highlight
fizzbuzz.py highlighted by val_highlight_flutter
DemoReal renders
val_highlight_flutter · 30 days
60.8K
val_highlight · 30 days
59.5K
Languages
55
Built-in themes
8

From pub.dev, 2026-11-13. Downloads count installs, not people. Languages and themes are counted from the engine's own registry.

01 · Editing

Colours that keep up with typing.

CodeField is a real Flutter text field that re-highlights on every keystroke. After an edit, only the lines it can affect are scanned again.

  • Line numbers, the current line and the matching bracket.
  • Or colour any TextField: a search box, a query input.
Incremental highlighting
02 · Themes

8 themes. Or your VS Code theme.

Light, dark and high-contrast themes are built in, and a VS Code colour theme file reads in as one.

  • One CodeTheme sets them app-wide.
  • Or build your own from scopes.
Themes
The sample in the Dark theme
03 · Languages

55 languages, one import each.

Each language is its own import, so an app ships only the grammars it needs. Hover one to see the names and file extensions it answers to.

  • bash
  • batch
  • c
  • clojure
  • cmake
  • cpp
  • csharp
  • css
  • dart
  • diff
  • dockerfile
  • elixir
  • erlang
  • fsharp
  • go
  • graphql
  • groovy
  • haskell
  • hcl
  • html
  • ini
  • java
  • javascript
  • json
  • jsx
  • julia
  • kotlin
  • latex
  • less
  • lua
  • makefile
  • markdown
  • nasm
  • nginx
  • objectivec
  • ocaml
  • perl
  • php
  • powershell
  • protobuf
  • python
  • r
  • ruby
  • rust
  • scala
  • scss
  • solidity
  • sql
  • swift
  • toml
  • tsx
  • typescript
  • xml
  • yaml
  • zig
04 · Widgets

Show it, edit it, make it yours.

CodeView to show code, CodeField to edit it, a controller for any TextField, and spans for your own widgets. Pick one to see the code and what it draws.

Fluttercode_view/line_numbers.dart
import 'package:material_ui/material_ui.dart';
import 'package:val_highlight/languages/kotlin.dart';
import 'package:val_highlight_flutter/val_highlight_flutter.dart';

/// Lines 12 to 19 of a longer file.
const excerpt = '''
fun total(items: List<Item>): Double {
    var sum = 0.0
    for (item in items) {
        sum += item.price * item.quantity
    }
    // Prices include tax.
    return sum
}''';

class Excerpt extends StatelessWidget {
  const Excerpt({super.key});

  
  Widget build(BuildContext context) {
    return const CodeView(
      excerpt,
      language: kotlinLanguage,
      lineNumbers: true,
      firstLineNumber: 12,
      highlightedLines: {14, 15, 16},
    );
  }
}
Rendered by val_highlight_flutterLine numbers docs
Line numbers, rendered from the flutter on the left

Each render is made from the code beside it.

Two libraries

Flutter widgets, and the Dart engine under them.

The widgets: CodeView to show code, CodeField to edit it, a controller for any TextField, and spans for your own widgets.

$ flutter pub add val_highlight_flutter

The engine: languages, themes, incremental updates, detection and highlighted HTML. On servers, in tools and compiled to JavaScript.

$ dart pub add val_highlight

A Flutter app adds both: the widgets, and the languages and themes, which are imported from val_highlight.

server.dart
import 'package:val_highlight/val_highlight.dart';
import 'package:val_highlight/languages/dart.dart';

final html = const Highlighter().toHtml(
  'final n = 42; // answer',
  language: dartLanguage,
  renderer: const HtmlRenderer(wrap: true),
);
What it returns
<pre class="vh"><code><span class="vh-keyword">final</span> n <span class="vh-operator">=</span> <span class="vh-number">42</span>; <span class="vh-comment">// answer</span></code></pre>

The output above was produced by running this code when the page was built.

HTML output

What comes next

Text is the first step. Ask below: the same answer becomes an interface, then a live scene.

Loading demo
  1. 01 · FreeThis page

    Output Rendering

    Markdown, math and code that render while the answer streams.

  2. 02 · Early accessNext step

    Generative UI

    Your team designs the components. The model fills them in. Your app draws them.

    How it works
  3. 03 · Private beta

    Live Scenes

    The answer as a narrated scene that people can steer and act on.

    How it works

Asked
first.

The short version for teams choosing a highlighter.

Make code readable.

Start with one widget; the docs cover the widgets, the themes and the full API.

Read the docs