Download this source code for
5 USD


Download this source code for
5 USD


Download this source code for
5 USD


Download this source code for
5 USD

better selection

experimental solution for web-like text selection across widgets (text, images, et cetera).

demo video

better selection is dependent on, and is heavily inspired by super_editor. it uses super_editor’s superselectabletext which allows a text selection to be passed in as an argument, as well as tapsequencegesturerecognizer for tripple click support.

this package is nowhere near stable, and many apis may change in the near future.

limitations

  • limited scrollable support. nested scrollviews and multiple scrollviews in a scope may behave unnaturally.
  • no “multiple column layout” support. using a scope on a row behaves very differently from how it would on web.
  • no mobile support

installation

to get started, add the git dependency to your pubspec.yaml.

better_selection:
  git:
    url: git://github.com/wilsonowilson/better_selection.git
    ref: main

usage

add the selectablescope widget

before doing anything, you must insert the selectablescope widget in your widget tree. you can place this widget wherever you want multiple text selection to take place.

class screen extends statelesswidget {
  const screen({key? key}) : super(key: key);

  @override
  widget build(buildcontext context) {
    return selectablescope(
      child: scaffold(
        body: column(
          children: [
             ...
          ],
        ),
      ),
    );
  }
}

all child widgets that implement selectablewidget can now be selected accross the scope.

default selectable widgets

by default, better_selection comes with two selectable widgets out of the box.

textselectable

a plain text widget. also supports rich text.

 textselectable.plain('lorem ipsum')

boxselectable

a selectablewidget that allows its child to be selected. example use cases would be copying images and icons. you can specify the copied text using the text parameter.

boxselectable(
  // making the copyable text html enables 
  // inter-application image pasting.
  text: '<img src="$imagelink">',
  child: image.network(imagelink),
),

Download this source code for
5 USD


Download this source code for
5 USD


Download this source code for
5 USD


Download this source code for
5 USD

Comments are closed.