flutter_selectext

Selectable text widget and able to set custom selection control.

image

Getting Started

Add dependencies

on pubspec.yaml

dependencies:
  flutter_selectext: ^0.1.1

Import library

import 'package:flutter_selectext/flutter_selectext.dart';

Usage

SelectableText

  • use string

     SelectableText('your string');
    
  • use textspan

     SelectableText.rich(textspan);
    

    SelectableText default only can copy.

    you can custom controls and could refer to MarkText widget.

MarkText

  • use string

      List<TextSelection> markList = List();
    
      void handlerMark(TextSelection selection) {
        setState(() {
          markList.add(selection);
        });
      }
    
      MarkText('your string',
        handlerMark: handlerMark,
        markColor: Colors.deepOrange,
        markList: markList);
    
  • use textspan

      List<TextSelection> markList = List();
    
      void handlerMark(TextSelection selection) {
        setState(() {
          markList.add(selection);
        });
      }
    
      MarkText(textspan,
        handlerMark: handlerMark,
        markColor: Colors.deepOrange,
        markList: markList);
    

Libraries

flutter_selectext

Dart

VM

dart:ffi
Foreign Function Interface for interoperability with the C programming language. [...]

Web

dart:html
HTML elements and other resources for web-based applications that need to interact with the browser and the DOM (Document Object Model). [...]
dart:js
Low-level support for interoperating with JavaScript. [...]
dart:js_util
Utility methods to efficiently manipulate typed JSInterop objects in cases where the name to call is not known at runtime. You should only use these methods when the same effect cannot be achieved with @JS annotations. These methods would be extension methods on JSObject if Dart supported extension methods.