Introduction au texte
pour l'affichagelettrecomposant. style de basestylecontrôle des attributs
Les attributs | effet |
---|---|
style | Style de police TextStyle |
texteAligner | Alignement du texte |
textDirection | sens du texte |
débordement | Le style affiché à la fin du texte ; |
textScaleFactor | rapport de taille de texte |
maxLignes | Nombre maximal de lignes |
Propriétés du style de texte TextStyle :
Les attributs | effet |
---|---|
couleur | couleur du texte |
Couleur de l'arrière plan | Couleur de l'arrière plan |
taille de police | taille de police |
fontWeight | poids de la police |
le style de police | le style de police |
l'espacement des lettres | l'espacement des lettres |
Espacement des mots | espacement par mot |
textBaseline | ligne de base du texte |
décoration | Ajouter surligner, souligner, barré |
décorationCouleur | couleur du tiret |
DécorationStyle | le style peut contrôler le dessin de lignes pleines, de lignes pointillées, de deux lignes, de points, de lignes ondulées, etc. |
créer un texte rouge
class TextWidget extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Container(
child: const Text(
'字体大小字体大小字体大小字体大小字体大小字体大小字体大小',
style: TextStyle(
backgroundColor: Colors.blueAccent,
color: Colors.red,
fontSize: 20,
fontWeight: FontWeight.w700,
// letterSpacing: 20,
textBaseline: TextBaseline.ideographic,
),
),
);
}
}
Attribut : ==letterSpacing== Définir letterSpacing=10
Il est clair que l'espacement des polices a changé
Attribut : hauteur : 2,0
Text('height: 用在Text控件上的时候,会乘以fontSize做为行高,所以这个值不能设置过大',
style: TextStyle(
color: Colors.green,
height: 2.0,
)),
décoration d'attribut : TextDecoration.overline)
Text('decoration: TextDecoration.overline 上划线',
style: TextStyle(
color: Colors.red,
decoration: TextDecoration.overline,
fontSize: 20,
decorationStyle: TextDecorationStyle.wavy)),
属性: décoration : TextDecoration.lineThrough
Text('decoration: TextDecoration.lineThrough 删除线',
style: TextStyle(
fontSize: 20,
decorationColor: Colors.blueAccent,
decoration: TextDecoration.lineThrough,
decorationStyle: TextDecorationStyle.dashed)),
Attribut : décoration : TextDecoration.underline
Text('decoration: TextDecoration.underline 下划线',
style: TextStyle(
decorationColor: Colors.red,
fontSize: 20,
decoration: TextDecoration.underline,
decorationStyle: TextDecorationStyle.dotted)),
Attributs : wordSpacing : 15.0
Text(
'wordSpacing: 字或单词间距',
style: TextStyle(
fontSize: 20,
// letterSpacing: 10.0,
wordSpacing: 10.0),
),
Attribut : letterSpacing : 10,0
Text(
'letterSpacing: 字符间距',
style: TextStyle(
letterSpacing: 10.0,
// wordSpacing: 15.0
),
),
Attribut : fontStyle : FontStyle.italic
Text(
'fontStyle: FontStyle.italic 斜体',
style: TextStyle(
fontStyle: FontStyle.italic,
),
),
Attribut : fontWeight : FontWeight.w700
Text(
'fontWeight: 字重',
style: TextStyle(fontSize: 30, fontWeight: FontWeight.w700),
),