flutter_trigger_input 0.2.0 copy "flutter_trigger_input: ^0.2.0" to clipboard
flutter_trigger_input: ^0.2.0 copied to clipboard

A powerful Flutter widget for detecting and handling triggers like mentions (@), and links. Supports deletion, and flexible suggestion engines.

flutter_trigger_input #

A screenshot of the iOS example app

A highly customizable Flutter widget for detecting and handling interactive triggers like mentions, hashtags, and links within a text field. It offers a seamless way to manage suggestion overlays with full generic type support and built-in markup parsing.

Getting Started #

To get a clear understanding of how this package works in a real-world scenario, we highly recommend checking out the included example.

Note: Run the example project to see the full implementation in action.

🚀 Usage #

Follow these steps to integrate Flutter Trigger Input into your project:

1. Initialize the Controller

Create an instance of TriggerInputController. This controller manages the detection logic and the state of your input field.

final TriggerInputController _controller = TriggerInputController();

2. Add the TriggerInputField Widget

Place the TriggerInputField in your widget tree. Pass the _controller and your initial list of suggestions (initSuggestList). This widget automatically detects trigger characters (like @) as the user types.

TriggerInputField(
  controller: _controller,
  initSuggestList: suggestions, // Your list of SuggestionInfo objects
  onMentionSearchChanged: onMentionSearchChanged,
),

3. Listen for Suggestions

To display a custom suggestion UI (like a ListView above the keyboard), listen to the suggestionInfos notifier. It updates in real-time based on the user's search keyword.

ValueListenableBuilder<List<SuggestionInfo>>(
  valueListenable: _controller.suggestionInfos,
  builder: (context, suggestions, child) {
    if (suggestions.isEmpty) return const SizedBox.shrink();

    return MySuggestionList(items: suggestions);
  },
)

Credits 👨‍💻 #

Issues and feedback 💭 #

If you have any suggestion for including a feature or if something doesn't work, feel free to open a Github issue for us to have a discussion on it.

6
likes
0
points
248
downloads

Publisher

unverified uploader

Weekly Downloads

A powerful Flutter widget for detecting and handling triggers like mentions (@), and links. Supports deletion, and flexible suggestion engines.

Repository (GitHub)
View/report issues

Topics

#chat #mention #hashtag #textfield #trigger

License

unknown (license)

Dependencies

flutter, json_annotation

More

Packages that depend on flutter_trigger_input