getAttributedText method

List<AttributedText> getAttributedText(
  1. String text,
  2. CometChatTheme theme,
  3. BubbleAlignment? alignment, {
  4. List<AttributedText>? existingAttributes,
  5. dynamic onTap(
    1. String
    )?,
  6. 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;
  }
}