createTextSpan static method
TextSpan
createTextSpan(
- String? text,
- CSSRenderStyle renderStyle, {
- Color? color,
- double? height,
- TextSpan? oldTextSpan,
Implementation
static TextSpan createTextSpan(
String? text,
CSSRenderStyle renderStyle, {
Color? color,
double? height,
TextSpan? oldTextSpan,
}) {
// Ensure font is loaded for the specific weight before creating TextStyle
List<String>? fontFamilies = renderStyle.fontFamily;
if (fontFamilies != null && fontFamilies.isNotEmpty) {
String primaryFontFamily = fontFamilies[0];
// Fire and forget - the font will be available for the next frame
CSSFontFace.ensureFontLoaded(primaryFontFamily, renderStyle.fontWeight, renderStyle);
}
TextStyle textStyle = createTextStyle(renderStyle, height: height, color: color);
if (oldTextSpan != null && oldTextSpan.text == text && oldTextSpan.style == textStyle) {
return oldTextSpan;
}
return TextSpan(text: text, style: textStyle, children: []);
}