highlight_selectable 0.1.4
highlight_selectable: ^0.1.4 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 #
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>[]
);
}
}