buildSpan method
Implementation
List<TextSpan> buildSpan(
BuildContext context, TextStyle? style, bool withComposing) {
List<TextSpan> textSpan = [];
List<AttributedText> attributedTexts = [];
for (CometChatTextFormatter formatter in formatters ?? []) {
attributedTexts = formatter.buildInputFieldText(
text: text,
style: style,
existingAttributes: attributedTexts,
context: context,
withComposing: withComposing,
theme: theme);
}
int start = 0;
for (AttributedText attributedText in attributedTexts) {
textSpan.add(TextSpan(
text: text.substring(start, attributedText.start),
style: TextStyle(
color: theme.palette.getAccent(),
fontWeight: theme.typography.body.fontWeight,
fontSize: theme.typography.body.fontSize,
fontFamily: theme.typography.body.fontFamily,
).merge(style),
));
textSpan.add(TextSpan(
text: attributedText.underlyingText ??
text.substring(attributedText.start, attributedText.end),
style: attributedText.style ??
TextStyle(
color: theme.palette.getAccent(),
fontWeight: theme.typography.body.fontWeight,
fontSize: theme.typography.body.fontSize,
fontFamily: theme.typography.body.fontFamily,
).merge(style),
));
start = attributedText.end;
}
textSpan.add(TextSpan(
text: text.substring(start),
style: TextStyle(
color: theme.palette.getAccent(),
fontWeight: theme.typography.body.fontWeight,
fontSize: theme.typography.body.fontSize,
fontFamily: theme.typography.body.fontFamily,
).merge(style),
));
return textSpan;
}