buildWithRegExp method
void
buildWithRegExp({
- required String data,
- required int start,
- required List<
RegExpSpecialText> copyRegExps, - required List<
InlineSpan> children, - TextStyle? textStyle,
- SpecialTextGestureTapCallback? onTap,
Implementation
void buildWithRegExp({
required String data,
required int start,
required List<RegExpSpecialText> copyRegExps,
required List<InlineSpan> children,
TextStyle? textStyle,
SpecialTextGestureTapCallback? onTap,
}) {
if (data.isEmpty) {
return;
}
if (copyRegExps.isEmpty) {
children.add(TextSpan(text: data, style: textStyle));
return;
}
final RegExpSpecialText regExpSpecialText = copyRegExps.first;
data.splitMapJoin(regExpSpecialText.regExp, onMatch: (Match match) {
final String matchString = '${match[0]}';
children.add(regExpSpecialText.finishText(
start,
match,
textStyle: textStyle,
onTap: onTap,
));
start += matchString.length;
return '';
}, onNonMatch: (String notMatch) {
if (notMatch.isNotEmpty) {
buildWithRegExp(
data: notMatch,
start: start,
children: children,
copyRegExps: copyRegExps.toList()..remove(regExpSpecialText),
textStyle: textStyle,
onTap: onTap,
);
start += notMatch.length;
}
return '';
});
}