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.
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.
- val_highlight_flutter
Flutter widgets for displaying and editing syntax-highlighted code.
80Compare - flutter_md
Fast Markdown parser and canvas renderer for Flutter with text selection and streaming.
82Compare - code_forge
A powerful text editor widget for Flutter handling 1M+ lines with LSP and AI completion.
81Compare - shiki_flutter
TextMate-grammar based syntax highlighter for Flutter ported from Shiki.
59Compare
Works with
Packages commonly used together with flutter_highlight: ones it builds on, ones built on it, and its own family.
- highlightflutter_highlight depends on itDart library that parses source code into syntax‑highlighted HTML
- flutter_code_editorBuilt on flutter_highlightA customizable code field widget supporting syntax highlighting and code folding.
- code_text_fieldBuilt on flutter_highlightA customizable code text field supporting syntax highlighting and scrolling.
- markdown_widgetBuilt on flutter_highlightA simple and easy-to-use markdown rendering component for Flutter.
- flutter_smooth_markdownBuilt on flutter_highlightHigh-performance markdown renderer and editor with syntax highlighting, LaTeX, tables, SVG, Mermaid, and real-time streaming.
- widget_with_codeviewBuilt on flutter_highlightA widget that displays a widget alongside its source code side-by-side.
- code_editorBuilt on flutter_highlightA Flutter code editor widget with syntax highlighting, custom themes, and file navigation.
- hyper_renderBuilt on flutter_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.