lasso_text_detector 0.0.1 copy "lasso_text_detector: ^0.0.1" to clipboard
lasso_text_detector: ^0.0.1 copied to clipboard

A Flutter package to detect and extract text by circling it with a lasso gesture.

Lasso Text Detector #

A Flutter package that allows users to select and extract text by circling it with a lasso gesture. Perfect for intuitive text selection in apps with heavy text content.

ezgif-493dddc612c460be

Features #

  • Gesture-based Selection: Draw any shape (lasso) to select text within the boundary.
  • Accurate Detection: Uses geometric intersection algorithms (Ray Casting & Segment Intersection) for high-precision character detection.
  • Support for Multiple Widgets: Seamlessly works with Text, RichText, and SelectableText.
  • Async API: Simple Future-based API to receive detection results directly from the controller.
  • Duplicate Prevention: Built-in logic to ensure each text element is captured only once, even with complex widget trees

Usage #

1. Initialize the Controller #

Create a LassoTextController to manage the state and results.

final _controller = LassoTextController();

@override
void dispose() {
  _controller.dispose();
  super.dispose();
}

2. Wrap your Widget #

Wrap the content you want to detect text from with LassoTextDetector.

LassoTextDetector(
  controller: _controller,
  lassoColor: Colors.blueAccent,
  strokeWidth: 2.0,
  child: ListView(
    children: [
      const Text('Try to circle this text!'),
      RichText(
        text: const TextSpan(
          text: 'You can also select ',
          children: [
            TextSpan(
              text: 'RichText segments.',
              style: TextStyle(fontWeight: FontWeight.bold),
            ),
          ],
        ),
      ),
    ],
  ),
)

3. Start and End Detection #

Control the lasso mode and wait for the results asynchronously.

// 1. Enter drawing mode
_controller.start();

// 2. Complete drawing and get results
final List<String>? results = await _controller.end();

if (results != null && results.isNotEmpty) {
  print('Detected segments: ${results.join(", ")}');
}
1
likes
160
points
150
downloads

Publisher

unverified uploader

Weekly Downloads

A Flutter package to detect and extract text by circling it with a lasso gesture.

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (license)

Dependencies

flutter

More

Packages that depend on lasso_text_detector