generate static method
List<InlineSpan>
generate(
- BuildContext context,
- String text,
- TextStyle? style,
- TextDirection textDirection,
- void onLinkTab()?,
Generate widget for markdown widget
Implementation
static List<InlineSpan> generate(
BuildContext context,
String text,
TextStyle? style,
TextDirection textDirection,
final void Function(String url, String title)? onLinkTab,
) {
List<InlineSpan> spans = [];
text.split(RegExp(r"\n+")).forEach(
(element) {
for (var each in components) {
if (each.exp.hasMatch(element.trim())) {
if (each is InlineMd) {
spans.add(each.span(
context,
element.trim(),
style,
textDirection,
onLinkTab,
));
spans.add(
TextSpan(
text: " ",
style: style,
),
);
} else {
if (each is BlockMd) {
spans.addAll([
TextSpan(
text: "\n ",
style: TextStyle(
fontSize: 0,
height: 0,
color: style?.color,
),
),
each.span(
context,
element.trim(),
style,
textDirection,
onLinkTab,
),
TextSpan(
text: "\n ",
style: TextStyle(
fontSize: 0,
height: 0,
color: style?.color,
),
),
]);
}
}
return;
}
}
},
);
return spans;
}