custom_selectable_text 0.4.0 copy "custom_selectable_text: ^0.4.0" to clipboard
custom_selectable_text: ^0.4.0 copied to clipboard

A widget like selectable text but with additional custom functions like share. It can do Copy, select all, cut and paste as well.

example/lib/main.dart

import 'package:custom_selectable_text/custom_selectable_text.dart';
import 'package:flutter/material.dart';

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

class MyApp extends StatelessWidget {
  const MyApp({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return const MaterialApp(
      home: HomePage(),
    );
  }
}

class HomePage extends StatelessWidget {
  const HomePage({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: Center(
        child: CustomSelectableText(
          "Lorem Ipsum",
          textAlign: TextAlign.center,
          items: [
            CustomSelectableTextItem.icon(
                icon: const Icon(Icons.copy),
                controlType: SelectionControlType.copy,
                onPressed: (text) {
                  ScaffoldMessenger.of(context).showSnackBar(SnackBar(
                    content: Text("Copied $text text"),
                  ));
                }),
            CustomSelectableTextItem.icon(
              controlType: SelectionControlType.selectAll,
              icon: const Icon(Icons.select_all),
            ),
            CustomSelectableTextItem.icon(
                icon: const Icon(Icons.share),
                onPressed: (text) {
                  ScaffoldMessenger.of(context).showSnackBar(SnackBar(
                    content: Text("Shared $text text"),
                  ));
                }),
            CustomSelectableTextItem.popUpMenuButton(
                child: PopupMenuButton(
              itemBuilder: (context) => [
                const PopupMenuItem(
                  child: Text("Text 1"),
                ),
                const PopupMenuItem(
                  child: Text("Text 2"),
                ),
              ],
            )),
          ],
        ),
      ),
    );
  }
}
10
likes
90
pub points
63%
popularity

Publisher

unverified uploader

A widget like selectable text but with additional custom functions like share. It can do Copy, select all, cut and paste as well.

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (LICENSE)

Dependencies

flutter

More

Packages that depend on custom_selectable_text