CometChatMentionsFormatter class

CometChatMentionsFormatter is a class which is used to format the mentions It extends the CometChatTextFormatter It has properties like composerId, onError, suggestionListEventSink, previousTextEventSink, message, mentionedUsersMap, mentionCount, mentionStartIndex, mentionEndIndex, lastCursorPos It has methods like handlePreMessageSend, initializeFetchRequest, fetchItems, onMessageEdit, resetMentionsTracker, cursorInMentionTracker, onChange, onScrollToBottom It has a constructor which takes trackingCharacter, pattern, disableSuggestions, showLoadingIndicator, onSearch, group, composerId, onError, suggestionListEventSink, previousTextEventSink, theme, message, messageBubbleTextStyle, groupMembersRequestBuilder, usersRequestBuilder, messageInputTextStyle as a parameter It has a method onMentionTap which is used to handle the mention tap

CometChatMentionsFormatter(
 trackingCharacter: "@",
 pattern: RegExp(RegexConstants.mentionRegexPattern),
 showLoadingIndicator: false,
 style: CometChatMentionsStyle(
  mentionTextColor: Colors.blue,
  mentionTextBackgroundColor: Colors.grey,
 ),
 );
Inheritance

Constructors

CometChatMentionsFormatter.new({String? trackingCharacter, RegExp? pattern, bool? showLoadingIndicator, dynamic onSearch(String?)?, OnError? onError, BaseMessage? message, TextStyle messageBubbleTextStyle(BuildContext context, BubbleAlignment? alignment, {bool? forConversation})?, TextStyle messageInputTextStyle(BuildContext context)?, Map<String, dynamic>? composerId, StreamSink<List<SuggestionListItem>>? suggestionListEventSink, StreamSink<String>? previousTextEventSink, User? user, Group? group, GroupMembersRequestBuilder? groupMembersRequestBuilder, UsersRequestBuilder? usersRequestBuilder, MentionsType? mentionsType, dynamic onMentionTap(String mention, User mentionedUser, {BaseMessage? message})?, MentionsVisibility? visibleIn, CometChatMentionsStyle? style})

Properties

composerId Map<String, dynamic>?
composerId is a Map which is used to store the composer id
getter/setter pairinherited
conflictingIndex int?
getter/setter pair
group Group?
set group for the formatter
getter/setter pairinherited
groupMembersRequestBuilder GroupMembersRequestBuilder?
groupMembersRequestBuilder is a GroupMembersRequestBuilder object which is used to get the group members
getter/setter pairinherited
hashCode int
The hash code for this object.
no setterinherited
hasMore bool
getter/setter pair
interceptedMention String?
getter/setter pair
lastCursorPos int
getter/setter pair
listItems List<User>
getter/setter pair
mentionCount Set<String>
getter/setter pair
mentionedUsersMap Map<String, List<User?>>
getter/setter pair
mentionEndIndex int
getter/setter pair
mentionsLimit int
getter/setter pair
mentionStartIndex int
getter/setter pair
mentionsType MentionsType?
mentionsType is a MentionsType object which is used to store the mentions type
getter/setter pair
mentionTracker String
getter/setter pair
message BaseMessage?
message is a BaseMessage which is used to store the message
getter/setter pairinherited
messageBubbleTextStyle TextStyle Function(BuildContext context, BubbleAlignment? alignment, {bool? forConversation})?
messageBubbleTextStyle is a function which is used to style the message bubble text with formatting
getter/setter pairinherited
messageInputTextStyle TextStyle Function(BuildContext context)?
messageBubbleTextStyle is a function which is used to style the message composer input text with formatting
getter/setter pairinherited
onError OnError?
onError callback triggered in case any error happens when fetching data
final
onMentionTap ↔ dynamic Function(String mention, User mentionedUser, {BaseMessage? message})?
onMentionTap is a Function(String mention, User mentionedUser, {BaseMessage? message}) which is used to handle the mention tap
getter/setter pair
onSearch ↔ dynamic Function(String?)?
onSearch is a function which is used to perform some action when the text is searched
getter/setter pairinherited
pattern RegExp?
pattern is a regular expression which is used to match the pattern
getter/setter pairinherited
previousTextEventSink StreamSink<String>?
previousTextEventSink is a StreamSink which is used to store the previous text event sink
getter/setter pairinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
searchOnActiveMention bool
getter/setter pair
showLoadingIndicator bool?
showLoadingIndicator is a boolean value which is used to show or hide the loading indicator
getter/setter pairinherited
style CometChatMentionsStyle?
style is a CometChatMentionsStyle object which is used to store the mentions style
getter/setter pair
suggestionListEventSink StreamSink<List<SuggestionListItem>>?
suggestionListEventSink is a StreamSink which is used to store the suggestion list event sink
getter/setter pairinherited
trackingCharacter String?
trackingCharacter is a string value which is used to track the character
getter/setter pairinherited
user User?
sets user for the formatter
getter/setter pairinherited
usersRequestBuilder UsersRequestBuilder?
usersRequestBuilder is a UsersRequestBuilder object which is used to get the users
getter/setter pairinherited
visibleIn MentionsVisibility?
visibleIn is a MentionsVisibility object which is used to store the mentions visibility
getter/setter pair

Methods

buildInputFieldText({required BuildContext context, TextStyle? style, required bool withComposing, required String text, List<AttributedText>? existingAttributes}) List<AttributedText>
buildInputFieldText is a function which is used to style the text in the input field in the message composer
override
checkIfTrackerPlacedCausesDuplication(int start, TextEditingController textEditingController) → void
cursorInMentionTracker(int cursorPosition, TextEditingController textEditingController, String previousText) → void
fetchItems({bool firstTimeFetch = false, required TextEditingController textEditingController, String? searchKeyword}) → void
fetchItems is a method which is used to fetch the items
getAttributedText(String text, BuildContext context, BubbleAlignment? alignment, {List<AttributedText>? existingAttributes, dynamic onTap(String)?, bool forConversation = false}) List<AttributedText>
getAttributedText is a function which is used to get the attributed text which is used to style the text in the message bubble and conversation subtitle
override
getLoadingIndicator(BuildContext context) Widget
getLoadingIndicator is a widget which is used to show the loading indicator
inherited
getMentionedUsers(String text) List<User>
getMessageBubbleTextStyle(BuildContext context, BubbleAlignment? alignment, {bool isLoggedInUser = false, bool forConversation = false}) TextStyle
getMessageBubbleTextStyle is a TextStyle object which is used to style the message bubble text
override
getMessageInputTextStyle(BuildContext context, {bool isLoggedInUser = false}) TextStyle
getMessageInputTextStyle is a TextStyle object which is used to style the message input text
override
handlePreMessageSend(BuildContext context, BaseMessage message) TextMessage
handlePreMessageSend is a method which is used to handle the pre message send context is a BuildContext which is used to build the widget message is a BaseMessage which is used to send the message
override
init() → void
override
initializeFetchRequest(String? searchKeyword, TextEditingController textEditingController) → void
initializeFetchRequest is a method which is used to initialize the fetch request
mergeAttributedText(List<AttributedText> attributedTexts, List<AttributedText> existingAttributedTexts) List<AttributedText>
mergeAttributedText is a function which is used to merge the attributed text of various formatters
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
onChange(TextEditingController textEditingController, String previousText) → void
onChange is a function which is used to perform some action when the text is changed
override
onMessageEdit(TextEditingController textEditingController, {List<User> mentionedUsers = const []}) → void
onMessageEdit is a method which is used to check the pattern matches text is a String which is used to store the text being typed cursorPosition is an int which is used to store the cursor position
onScrollToBottom(TextEditingController textEditingController) → void
onScrollToBottom is a function which is used to perform some action when the scroll reaches the bottom of the suggestion list
override
resetMentionsTracker() → void
setMentionedUsers(List<User> mentionedUsers) → void
toString() String
A string representation of this object.
inherited
updatePreviousText(String text) → void

Operators

operator ==(Object other) bool
The equality operator.
inherited

Static Methods

getMentionedUserName(String uid, BaseMessage message) String
getTextWithMentions(String text, List<User> mentionedUsers) String