πŸ“š 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.2.1

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']!,  // Note: theme keys use underscores
      selectable: true,
      showCopyButton: true,
      showEditButton: true,
      onChanged: (newCode) {
        // Handle code changes
        debugPrint('User updated the code:\n$newCode');
      },
      // onCopied: () {},
      // overlayButtons: [CustomButton()],
    );
  }
}

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