flutter_highlighting

Code syntax highlighting library for over 190 languages.

If you are looking for the pure Dart package, see highlighting.

This package is a port of HighlightJS project into Dart. It is periodically updated from the original JavaScript version with an automated script.

Usage

import 'package:flutter/material.dart';
import 'package:flutter_highlighting/flutter_highlighting.dart';
import 'package:flutter_highlighting/themes/github.dart';
import 'package:highlighting/languages/dart.dart';

class MyWidget extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    final code = '''main() {
  print("Hello, World!");
}
''';

    return HighlightView(
      // The original code to be highlighted
      code,

      // Specify language
      // It is recommended to give it a value for performance
      languageId: dart.id,

      // Specify highlight theme
      // All available themes are listed in `themes` folder
      theme: githubTheme,

      // Specify padding
      padding: EdgeInsets.all(12),

      // Specify text style
      textStyle: TextStyle(
        fontFamily: 'My awesome monospace font',
        fontSize: 16,
      ),
    );
  }
}

Versions and Migration

The package uses its own version numbering in addition to that of HighlightJS. For example, the version 0.9.0+11.8.0 means that it is:

  • Version 0.9.0 of the Dart package itself, and it contains breaking changes over the version 0.8.x.
  • Ported from HighlightJS version 11.8.0.

This allows the pub tool to automatically guard you against breaking changes.

Migration guides:

Maintainer's Guide

References

Libraries

flutter_highlighting
theme_map
themes/a11y-dark
themes/a11y-light
themes/agate
themes/an-old-hope
themes/androidstudio
themes/arduino-light
themes/arta
themes/ascetic
themes/atelier-cave-dark
themes/atelier-cave-light
themes/atelier-dune-dark
themes/atelier-dune-light
themes/atelier-estuary-dark
themes/atelier-estuary-light
themes/atelier-forest-dark
themes/atelier-forest-light
themes/atelier-heath-dark
themes/atelier-heath-light
themes/atelier-lakeside-dark
themes/atelier-lakeside-light
themes/atelier-plateau-dark
themes/atelier-plateau-light
themes/atelier-savanna-dark
themes/atelier-savanna-light
themes/atelier-seaside-dark
themes/atelier-seaside-light
themes/atelier-sulphurpool-dark
themes/atelier-sulphurpool-light
themes/atom-one-dark
themes/atom-one-dark-reasonable
themes/atom-one-light
themes/brown-paper
themes/codepen-embed
themes/color-brewer
themes/darcula
themes/dark
themes/default
themes/devibeans
themes/docco
themes/dracula
themes/far
themes/felipec
themes/foundation
themes/github
themes/github-dark
themes/github-dark-dimmed
themes/github-gist
themes/gml
themes/googlecode
themes/gradient-dark
themes/gradient-light
themes/grayscale
themes/gruvbox-dark
themes/gruvbox-light
themes/hopscotch
themes/hybrid
themes/idea
themes/intellij-light
themes/ir-black
themes/isbl-editor-dark
themes/isbl-editor-light
themes/kimbie-dark
themes/kimbie-light
themes/kimbie.dark
themes/kimbie.light
themes/lightfair
themes/lioshi
themes/magula
themes/mono-blue
themes/monokai
themes/monokai-sublime
themes/night-owl
themes/nnfx-dark
themes/nnfx-light
themes/nord
themes/obsidian
themes/ocean
themes/panda-syntax-dark
themes/panda-syntax-light
themes/paraiso-dark
themes/paraiso-light
themes/pojoaque
themes/purebasic
themes/qtcreator-dark
themes/qtcreator-light
themes/qtcreator_dark
themes/qtcreator_light
themes/railscasts
themes/rainbow
themes/routeros
themes/school-book
themes/shades-of-purple
themes/solarized-dark
themes/solarized-light
themes/srcery
themes/stackoverflow-dark
themes/stackoverflow-light
themes/sunburst
themes/tokyo-night-dark
themes/tokyo-night-light
themes/tomorrow
themes/tomorrow-night
themes/tomorrow-night-blue
themes/tomorrow-night-bright
themes/tomorrow-night-eighties
themes/vs
themes/vs2015
themes/xcode
themes/xt256
themes/zenburn