buildInputFieldText method
List<AttributedText>
buildInputFieldText({
- required BuildContext context,
- TextStyle? style,
- required bool withComposing,
- required String text,
- CometChatTheme? theme,
- List<
AttributedText> ? existingAttributes,
override
buildInputFieldText is a function which is used to style the text in the input field in the message composer
Implementation
@override
List<AttributedText> buildInputFieldText(
{required BuildContext context,
TextStyle? style,
required bool withComposing,
required String text,
CometChatTheme? theme,
List<AttributedText>? existingAttributes}) {
List<AttributedText> attributedTexts = [];
mentionedUsersMap.forEach((username, userObjects) {
final matches = RegExp(username).allMatches(text);
List<AttributedText> currentAttributedTexts = [];
for (int i = 0; i < matches.length; i++) {
try {
if (userObjects[i] != null) {
currentAttributedTexts.add(AttributedText(
start: matches.elementAt(i).start,
end: matches.elementAt(i).end,
underlyingText: username,
style: getMessageInputTextStyle(theme!,
isLoggedInUser: userObjects[i]?.uid ==
CometChatUIKit.loggedInUser?.uid)));
}
} catch (error) {
if (kDebugMode) {
print("error in mentions input $error");
}
break;
}
}
attributedTexts.addAll(currentAttributedTexts);
});
return mergeAttributedText(attributedTexts, existingAttributes ?? []);
}