highlight_selectable 0.1.4 copy "highlight_selectable: ^0.1.4" to clipboard
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.

example/lib/main.dart

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

void main() {
  runApp(const HighlightDemoApp());
}

class HighlightDemoApp extends StatelessWidget {
  const HighlightDemoApp({super.key});

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Highlight Selectable Demo',
      theme: ThemeData.dark(),
      home: const HighlightHomePage(),
    );
  }
}

class HighlightHomePage extends StatefulWidget {
  const HighlightHomePage({super.key});

  @override
  State<HighlightHomePage> createState() => _HighlightHomePageState();
}

class _HighlightHomePageState extends State<HighlightHomePage> {
  bool _isSelectable = false;

  final String _code = '''
void main();
''';

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: const Text('Highlight Selectable Demo'),
        actions: [
          Row(
            children: [
              const Text("Selectable"),
              Switch(
                value: _isSelectable,
                onChanged: (value) {
                  setState(() {
                    _isSelectable = value;
                  });
                },
              ),
            ],
          ),
        ],
      ),
      body: Padding(
        padding: const EdgeInsets.all(16.0),
        child: HighlightSelectable(
        _code,
        language: 'dart',
          padding: const EdgeInsets.all(16.0),
        theme: themeMap['a11y-dark']!,
        selectable: _isSelectable,
        showCopyButton: false,
        showEditButton: true,
        showLanguage: true,
        onChanged: (updatedCode) {
          print("Edited code: $updatedCode");
        },
      ),
      ),
    );
  }
}
0
likes
140
points
254
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