toTextStyle method
Преобразует атрибуты Delta в TextStyle
Implementation
TextStyle toTextStyle(TextStyle? base) {
if (this == null) return base ?? const TextStyle();
final attr = this!;
final hasLink = attr['link'] is String;
final decorations = [
if (attr['underline'] == true) TextDecoration.underline,
if (attr['strike'] == true) TextDecoration.lineThrough,
];
return (base ?? const TextStyle()).copyWith(
fontWeight: attr['bold'] == true ? FontWeight.bold : null,
fontStyle: attr['italic'] == true ? FontStyle.italic : null,
decoration: decorations.isNotEmpty ? TextDecoration.combine(decorations) : null,
// Цвет ссылки по умолчанию, если не задан явно атрибутом color
color: _parseColor(attr['color']) ?? (hasLink ? const Color(0xFF3386FB) : null),
backgroundColor: _parseColor(attr['background']),
fontFamily: attr['font'] as String?,
fontSize: _parseFontSize(attr['size']),
);
}