Flutter Mentions는 텍스트 입력 필드에 @멘션 기능을 추가하는 가벼운 Flutter 패키지입니다. 사용자가 텍스트 내에서 다른 사람을 태그할 수 있도록 해줍니다. 실시간 제안을 지원하며 양식이나 채팅 인터페이스에 원활하게 통합됩니다. 위젯은 사용자 정의가 가능하며 Android, iOS, Web, macOS, Windows, Linux 등 주요 플랫폼에서 작동합니다. 소셜 미디어 앱, 메시징 플랫폼 또는 사용자 태깅이 필요한 협업 도구에 적합합니다.
사용 사례
소셜 미디어 앱
메시징 인터페이스
협업 콘텐츠 편집
댓글 내 사용자 태그
실시간 채팅 기능
주요 기능
@mention 제안 드롭다운
크로스 플랫폼 호환성
사용자 정의 스타일
TextFormField와의 간편한 통합
언급에 대한 실시간 필터링
적합한 대상
채팅 앱을 개발하는 개발자
소셜 플랫폼을 만드는 팀
사용자 태그가 필요한 앱
텍스트 입력용 UI 컴포넌트
크로스 플랫폼 요구 사항이 있는 프로젝트
고려 사항
멘션 데이터를 수동으로 처리해야 합니다
기본 언급 로직에 국한됨
내장 백엔드 지원 없음
추가 검증이 필요할 수 있습니다
스타일 사용자 정의에는 코드 조정이 필요합니다
원본 README
연결된 소스 저장소의 README 원문 스냅샷입니다. 최신 내용은 저장소에서 확인하세요.
📛 Flutter Mentions
A simple flutter input widget to add @ mentions functionality to your app
You will need to add flutter_mentions to your pubspec.yaml:
dependencies:flutter:sdk:flutterflutter_mentions:
Then, run flutter packages get in your terminal.
Usage 💻
To use this package you must first wrap your top most widget with Portal as this package uses flutter_portal to show the suggestions list.
[Portal], is the equivalent of [Overlay].
This widget will need to be inserted above the widget that needs to render
under your overlays.
If you want to display your overlays on the top of everything, a good place
to insert that [Portal] is above MaterialApp:
Portal(
child: MaterialApp(
...
)
);
(works for CupertinoApp too)
This way [Portal] will render above everything. But you could place it
somewhere else to change the clip behavior.
Widgets:
FlutterMention
mentions: List<Mention> - List of Mention that the user is allowed to triggered.
suggestionPosition: SuggestionPosition - Suggestion modal position, can be alligned to [Top] or [Bottom].
onMentionAdd: Function(Map<String, dynamic>) - Triggers when the suggestion was added by tapping on suggestion.
suggestionListHeight: double - Max height for the suggestion list. Defaults for 300.0.
onMarkupChanged: Function(String) - A Functioned which is triggered when ever the input changes but with the markup of the selected mentions.
suggestionListDecoration: BoxDecoration - Decoration for the Suggestion list.
defaultText: String - Populate your input field with pre-filled text.
onSearchChange: Function(String trigger, String value) - Fired only when the input changes & user is searching a mention item.
leading: List<Widget> - List of widgets that should be placed before the input.
trailing: List<Widget> - List of widgets that should be placed after the input.
onSuggestionVisibleChanged: Function(bool) - Triggers when the suggestion list visibility changed.
Supports all the other properties that TextField supports.
Mention
trigger: String - A single character that will be used to trigger the suggestions.
data: List<Map<String, dynamic>> - List of Map to represent the suggestions shown to the user. You need to provide two Required properties id & display both are [String] You can also have any custom properties as you like to build custom suggestion widget (NOTE: this can later be updated to show new or filtered mention list).
style: TextStyle - Style for the mention item in Input.
matchAll: bool - Should every non-suggestion with the trigger character be matched.
disableMarkup: bool - Should the markup generation be disabled for this Mention Item.
suggestionBuilder: Widget Function(Map<String, dynamic>) - Build Custom suggestion widget using this builder.
markupBuilder: String Function(String trigger, String mention, String value) - Used to define how the mentions markup should be saved.
1. How do I can access to the the editing controller?
A. To get the control of TextEditingController just use a Global key more info can be found here #13. This will also allow you to access the text & markupText.
2. How do I search users as I type?
A. Just use the onSearchChange to get the currrent search text & make request to the server and later update the data.
3. What is the need of Portal?
A. You should check this comment where I mentioned in more detail the reason behind using portal.