Skip to content
pubscout

flutter_highlight

0.7.0, released 6 years ago by an unverified publisher

A Flutter widget that highlights source code with many languages and themes.

WASM-ready
$ flutter pub add flutter_highlight
Source repository

What it does

Provides a HighlightView widget that renders code with syntax coloring based on the Highlight.js library. It includes a collection of language definitions and visual themes. The widget works on all Flutter platforms and supports null safety.

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

Use it when

  • You need to display read‑only source code with syntax highlighting in a Flutter app.
  • You want a wide range of language support and ready‑made themes without writing your own parser.

Skip it when

  • You need an editable code editor with features like autocomplete or linting.
  • You are highlighting extremely large files where performance becomes critical.

Strengths

  • Supports dozens of languages and many themes
  • Null‑safe and works on Android, iOS, web, desktop
  • Pure Dart, no native setup required

Weaknesses

  • Only for display, not editing
  • Performance may degrade with very large code blocks
  • No built‑in line numbers or advanced UI features

Setup

Kind
Flutter widgets
Effort
Low
Code generation
No
Direct dependencies
1
import 'package:flutter/material.dart';
import 'package:flutter_highlight/flutter_highlight.dart';
import 'package:flutter_highlight/themes/github.dart';

class MyWidget extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    const code = '''main() {
  print("Hello, World!");
}''';
    return HighlightView(
      code,
      language: 'dart',
      theme: githubTheme,
      padding: EdgeInsets.all(12),
      textStyle: TextStyle(fontFamily: 'monospace', fontSize: 16),
    );
  }
}

Alternatives

Packages that do the same job and could replace flutter_highlight.

Works with

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