📚 highlight_selectable

pub package license: MIT

A Flutter widget that displays syntax-highlighted code with optional selection, copy, and inline editing support — an enhanced version of flutter_highlight, made to feel more like ChatGPT or VSCode snippets.


✨ Features

  • ✅ Syntax highlighting using highlight
  • ✅ Toggle between selectable or read-only code
  • ✅ Optional copy button
  • ✅ Built-in edit mode with save/cancel controls
  • ✅ Support for custom overlay buttons (e.g. share, delete, etc.)
  • ✅ All themes from flutter_highlight are supported
  • ✅ Fully Flutter & web compatible (no dart:io)

📦 Installation

dependencies:
  highlight_selectable: ^0.1.0

Quick Start

import 'package:flutter/material.dart';
import 'package:highlight_selectable/theme_map.dart';
import 'package:highlight_selectable/highlight_selectable.dart';

class Example extends StatelessWidget {
  final code = "print('Hello, world!');"

  @override
  Widget build(BuildContext context) {
    return HighlightSelectable(
      code,
      language: 'dart',
      theme: themeMap['a11y-dark']!,
      selectable: true,
      showCopyButton: true,
      showEditButton: true,
      onChanged: (newCode) => print('User updated the code:\n$newCode'),
      // onCopied: (){},
      // overlayButtons: List<Widget>[]
    );
  }
}

Libraries

highlight_selectable
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/docco
themes/dracula
themes/far
themes/foundation
themes/github
themes/github-gist
themes/gml
themes/googlecode
themes/gradient-dark
themes/grayscale
themes/gruvbox-dark
themes/gruvbox-light
themes/hopscotch
themes/hybrid
themes/idea
themes/ir-black
themes/isbl-editor-dark
themes/isbl-editor-light
themes/kimbie.dark
themes/kimbie.light
themes/lightfair
themes/magula
themes/mono-blue
themes/monokai
themes/monokai-sublime
themes/night-owl
themes/nord
themes/obsidian
themes/ocean
themes/paraiso-dark
themes/paraiso-light
themes/pojoaque
themes/purebasic
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/sunburst
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