这是indexloc提供的服务,不要输入任何密码
Skip to content

Rac0n/highlight_selectable

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

📚 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>[]
    );
  }
}

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published