Skip to content
pubscout

flutter_taggable

1.1.2, released 2 years ago by wesselvandam.com

Lightweight TextEditingController extension for user mentions, hashtags, and entity tagging.

WASM-ready
$ flutter pub add flutter_taggable
Source repository

What it does

Extends the standard TextField with a TagTextEditingController to let users mention users or insert hashtags. It parses tags into database-friendly formats and converts them into frontend display representations or InlineSpans.

AI-written summary of version 1.1.2, based on the package's README and metadata. Report an inaccuracy

Use it when

  • You need user mentions or hashtags in a text input field.
  • You want database-friendly tag representation (e.g., storing IDs instead of display names).

Skip it when

  • You are not using standard TextField widgets.
  • You require complex WYSIWYG rich text editor features beyond inline mentions.

Strengths

  • Integrates seamlessly with the standard TextField widget.
  • Handles backspacing over a tag by deleting the entire tag automatically.
  • Supports customizable tag styles and multiple tagging prefixes.

Weaknesses

  • Cursor position and selection ranges around tags can have imperfect behavior.
  • Requires manual implementation of overlay/search UI through callbacks.

Setup

Kind
Flutter widgets
Effort
Low
Code generation
No
Direct dependencies
0
class TaggableExample extends StatefulWidget {
  @override
  _TaggableExampleState createState() => _TaggableExampleState();
}

class _TaggableExampleState extends State<TaggableExample> {
  late TagTextEditingController _controller;

  @override
  void initState() {
    super.initState();
    _controller = TagTextEditingController<Taggable>(
      searchTaggables: searchTaggables,
      buildTaggables: buildTaggables,
      toFrontendConverter: (taggable) => taggable.name,
      toBackendConverter: (taggable) => taggable.id,
      tagStyles: {
        '@': const TextStyle(color: Colors.blue),
        '#': const TextStyle(color: Colors.green),
      },
    );
  }

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

  @override
  Widget build(BuildContext context) {
    return TextField(controller: _controller);
  }
}

Alternatives

Packages that do the same job and could replace flutter_taggable.