highlight_selectable 0.2.1 copy "highlight_selectable: ^0.2.1" to clipboard
highlight_selectable: ^0.2.1 copied to clipboard

A Flutter widget that displays syntax-highlighted code blocks, with support for selection, copy button, and inline editing. Based on flutter_highlight and highlight.

πŸ“š 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()],
    );
  }
}
1
likes
160
points
76
downloads

Publisher

unverified uploader

Weekly Downloads

A Flutter widget that displays syntax-highlighted code blocks, with support for selection, copy button, and inline editing. Based on flutter_highlight and highlight.

Repository (GitHub)
View/report issues

Topics

#flutter #highlight #code #editor #syntax

Documentation

Documentation
API reference

License

MIT (license)

Dependencies

flutter, highlight

More

Packages that depend on highlight_selectable