generateTextSpans method
Implementation
List<TextSpan> generateTextSpans(String text) {
final List<TextSpan> spans = [];
final TextStyle emojiStyle = style.copyWith(
fontSize: style.fontSize! *
(Platform.isAndroid ? 1.12 - 0.05 * 34 / style.fontSize! : 0.9),
letterSpacing: 2,
);
final TextStyle boldStyle = style.copyWith(fontWeight: boldWeight);
text.splitMapJoin(
emojiRegex,
onMatch: (m) {
spans.add(
TextSpan(
text: m.group(0),
style: emojiStyle,
),
);
return '';
},
onNonMatch: (s) {
return s.splitMapJoin(
boldRegex,
onMatch: (m) {
spans.add(
TextSpan(
text: m.group(1),
style: boldStyle,
),
);
return '';
},
onNonMatch: (st) {
spans.add(TextSpan(text: st));
return '';
},
);
},
);
return spans;
}