renderSpan function
Implementation
String renderSpan(TextSpan span, Style? baseStyle) {
final buffer = StringBuffer();
Style? resolvedStyle;
if (baseStyle != null || span.style != null) {
resolvedStyle = (baseStyle ?? Style()).copy();
if (span.style != null) {
resolvedStyle.inherit(span.style!);
}
resolvedStyle.hasDarkBackground = hasDarkBackground;
}
final text = span.text;
if (text != null && text.isNotEmpty) {
if (resolvedStyle != null) {
buffer.write(resolvedStyle.render(text));
} else {
buffer.write(text);
}
}
if (span.children.isNotEmpty) {
for (final child in span.children) {
buffer.write(renderSpan(child, resolvedStyle ?? baseStyle));
}
}
return buffer.toString();
}