Search categories, packages and repositories

mentionable_text_field cover
Package detailsv0.0.2

mentionable_text_field

A flutter plugin to create customizable text field that has a mentionable feature. The way matching users are displayed and picked is decorrelated from the Widget itself, so that you will be able to chose the way you will do.

AndroidiOSWebmacOSWindowsLinux
30-day downloads
267
Likes
35
Pub points
130

Install package

flutter pub add mentionable_text_field

Package Overview

Package selection guidance compiled from public package information, community data, and project usage.

A customizable Flutter text field plugin that enables mention functionality, allowing users to tag others within text. It separates the logic of matching and displaying mentions from the UI, offering flexibility in how suggestions are presented and selected. Ideal for chat or social apps, it supports multiple platforms including Android, iOS, Web, macOS, Windows, and Linux. The plugin is designed for developers who want full control over the mention experience without being tied to a specific UI component.

Use cases

  • Chat applications
  • Social media platforms
  • Collaborative editing tools
  • User tagging in comments
  • Real-time messaging interfaces
  • Content creation with mentions

Key features

  • Decoupled mention display and selection
  • Customizable suggestion UI
  • Cross-platform support
  • Extensible matching logic
  • Configurable trigger characters
  • Integration-friendly design

Suitable for

  • Developers building rich text input
  • Apps requiring user tagging
  • Teams needing flexible mention systems
  • Projects with custom UI requirements
  • Flutter apps targeting multiple platforms

Considerations

  • Requires custom implementation for suggestion rendering
  • May need additional state management
  • Not suitable for simple text inputs
  • Depends on external logic for user matching
  • Limited built-in styling options
  • Needs careful handling of text cursor and selection

Original README

Original README snapshot from the linked source repository. Visit the repository for the latest content.

mentionable_text_field

A flutter plugin to create customizable text field that has a mentionable feature.

Installing:

In your pubspec.yaml

dependencies:
  mentionable_text_field: ^0.0.2
import 'package:mentionable_text_field/mentionable_text_field.dart';


Basic Usage:

    class _MyHomePageState extends State<MyHomePage> {
  List<Mentionable> _mentionableUsers = [];
  late void Function(Mentionable mentionable) _onSelectMention;

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text(widget.title),
      ),
      body: SafeArea(
        child: Stack(
          children: [
            Positioned(
              bottom: 0,
              width: MediaQuery.of(context).size.width,
              height: 200,
              child: Column(
                children: [
                  MentionableTextField(
                    onControllerReady: (value) =>
                    _onSelectMention = value.pickMentionable,
                    maxLines: 1,
                    onSubmitted: print,
                    mentionables: const [
                      MyUser('John Doe'),
                      MyUser('Jeanne Aulas'),
                      MyUser('Alexandre Dumas')
                    ],
                    onMentionablesChanged: (mentionableUsers) =>
                        setState(() => _mentionableUsers = mentionableUsers),
                    decoration:
                    const InputDecoration(hintText: 'Type something ...'),
                  ),
                  Expanded(
                    child: ListView.builder(
                      itemBuilder: (context, index) {
                        final mentionable = _mentionableUsers[index];
                        return ListTile(
                          leading: const Icon(Icons.person),
                          title: Text(mentionable.label),
                          onTap: () => _onSelectMention(mentionable),
                        );
                      },
                      itemCount: _mentionableUsers.length,
                    ),
                  )
                ],
              ),
            )
          ],
        ),
      ),
    );
  }
}



Custom usage

In addition to basic textField's attributes, There are other options:\

Properties Description
ValueChanged<MentionTextEditingController>? onControllerReady A callback to retrieve the TextField controller when ready
List<Mentionable> mentionables List of possible Mentionable objects, eg: users.
String escapingMentionCharacter The character used to replace mention. It should not be used by the user to avoid issues. It should be a single character.
MentionablesChangedCallback onMentionablesChanged Callback that is called on each new characters typed in TextField. It gives the current candidates to mention feature.
TextStyle mentionStyle Text Style applied to mentions

Additional information

Don't hesitate to suggest any features or fix that will improve the package!

Categories

Source repository

Projects using this package

No data available yet.