一 文本组件Text
- 有序列表第一项
Text('You have11 pushed the button this many times:',
textAlign: TextAlign.left,
style: TextStyle(
fontSize: 40,
color: Colors.red,
backgroundColor: Colors.blue,
),
二 富文本组件RichText
RichText(
text: TextSpan(style: const TextStyle(), children: [
TextSpan(
text: '这是一个链接',
style: const TextStyle(
fontSize: 20.0,
color: Colors.red,
),
)
]
),
),
2.Text.rich
Text.rich(
TextSpan(
children: [
TextSpan(
text: "home"
),
TextSpan(
text: "https:wwww",
style: TextStyle(
color: Colors.red,
),
)
] )),
截屏2023-06-28 10.59.22.png
- DefaultTextStyle
DefaultTextStyle(style: TextStyle(
color: Colors.red,
fontSize: 30,
), child: Column(
children: [
Text('www'),
Text('ddd'),
Text('特别',
style: TextStyle(
inherit: false,//不继承默认样式
color: Colors.blue,
fontSize: 50
),
),
],
)
),
截屏2023-06-28 11.23.22.png
- crossAxisAlignment: CrossAxisAlignment.start, // 加入布局 这句话 ,变为右对齐
DefaultTextStyle(
style: TextStyle(
color: Colors.red,
fontSize: 30,
),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start, // 加入布局 这句话
children: [
Text('www'),
Text('ddd'),
Text('特别',
style: TextStyle(
inherit: false,//不继承默认样式
color: Colors.blue,
fontSize: 50
),
),
],
)
),
截屏2023-06-28 11.27.36.png