getAttributedText method
List<AttributedText>
getAttributedText(
- String text,
- CometChatTheme theme,
- BubbleAlignment? alignment, {
- List<
AttributedText> ? existingAttributes, - dynamic onTap()?,
- bool forConversation = false,
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
Implementation
List<AttributedText> getAttributedText(
String text, CometChatTheme theme, BubbleAlignment? alignment,
{List<AttributedText>? existingAttributes,
Function(String)? onTap,
bool forConversation = false}) {
List<AttributedText> attributedTexts = [];
final matches = pattern!.allMatches(text);
attributedTexts = matches.map((match) {
int start = match.start;
int end = match.end;
return AttributedText(
start: start,
end: end,
style: getMessageBubbleTextStyle(theme, alignment,
forConversation: forConversation),
onTap: onTap);
}).toList();
if (existingAttributes != null && existingAttributes.isNotEmpty) {
return mergeAttributedText(attributedTexts, existingAttributes);
} else {
return attributedTexts;
}
}