capitalize method
capitalize: text-transform: capitalize; ✅ 支持:通过字符串转换实现,首字母大写
Implementation
TextBuilder capitalize() {
String capitalizedText = text.split(' ').map((word) {
if (word.isEmpty) return word;
return word[0].toUpperCase() + word.substring(1).toLowerCase();
}).join(' ');
return TextBuilder(capitalizedText)
.._color = _color
.._fontSize = _fontSize
.._fontWeight = _fontWeight
.._fontStyle = _fontStyle
.._letterSpacing = _letterSpacing
.._wordSpacing = _wordSpacing
.._height = _height
.._decoration = _decoration
.._decorationColor = _decorationColor
.._decorationStyle = _decorationStyle
.._decorationThickness = _decorationThickness
.._shadows = _shadows
.._fontFamily = _fontFamily
.._textBaseline = _textBaseline
.._overflow = _overflow
.._maxLines = _maxLines
.._textAlign = _textAlign
.._locale = _locale;
}