flutter_selectext 0.1.1 copy "flutter_selectext: ^0.1.1" to clipboard
flutter_selectext: ^0.1.1 copied to clipboard

Selectable text widget and able to set custom selection control.

example/example.dart

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

void main() {
  runApp(new DemoApp());
}

class DemoApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Demo',
      theme: ThemeData(
        primarySwatch: Colors.grey,
      ),
      home: const SelectableTextDemo(),
    );
  }
}

class SelectableTextDemo extends StatefulWidget {
  const SelectableTextDemo({Key key}) : super(key: key);

  @override
  _SelectableTextDemoState createState() => _SelectableTextDemoState();
}

class _SelectableTextDemoState extends State<SelectableTextDemo> {
  List<TextSelection> markList = List();

  @override
  void initState() {
    super.initState();
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: const Text('Selectable Text Demo'),
      ),
      body: Center(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          mainAxisSize: MainAxisSize.min,
          crossAxisAlignment: CrossAxisAlignment.stretch,
          children: <Widget>[
            MarkText.rich(
              TextSpan(children: [
                TextSpan(
                    style: TextStyle(
                        color: Colors.amber,
                        fontSize: 30,
                        wordSpacing: 3,
                        shadows: [
                          Shadow(
                              color: Colors.black,
                              offset: Offset(6, 3),
                              blurRadius: 10)
                        ]),
                    text: 'This has mark option'),
                TextSpan(
                    style: TextStyle(
                      color: Colors.deepPurple,
                    ),
                    text: ' test test test!!'),
              ]),
              handlerMark: (TextSelection selection) {
                setState(() {
                  markList.add(selection);
                });
              },
              markColor: Colors.deepOrange,
              markList: markList,
            ),
            SelectableText.rich(
              TextSpan(
                children: [
                  TextSpan(
                      style: TextStyle(
                        color: Colors.amber,
                        fontSize: 30,
                        wordSpacing: 3,
                        shadows: [
                          Shadow(
                              color: Colors.black,
                              offset: Offset(6, 3),
                              blurRadius: 10),
                        ],
                      ),
                      text: 'You have pushed the'),
                  TextSpan(
                      style: TextStyle(
                        color: Colors.blueAccent,
                      ),
                      text: 'button this many times:'),
                ],
              ),
            ),
          ],
        ),
      ),
    );
  }
}
3
likes
30
points
34
downloads

Publisher

unverified uploader

Weekly Downloads

Selectable text widget and able to set custom selection control.

Repository (GitHub)

License

unknown (license)

Dependencies

flutter

More

Packages that depend on flutter_selectext