我有RichText
分加TextSpan
分.我想让TextSpan
个小部件中的一个有它的背景,所以我使用background: Paint()..color = Colors.redAccent
作为它的文本样式.
有没有办法给背景增加一些额外的红色空格/填充.
这就是它目前的样子:
这是我想要的外观(请注意高亮文本顶部和底部的额外红色):
以下是使用的代码:
Scaffold(
appBar: new AppBar(),
body: new RichText(
text: new TextSpan(
text: 'This is a one the lines in the span \n ',
style: TextStyle(fontSize: 15.0, color: Colors.black),
children: <TextSpan>[
new TextSpan(
text: 'This is the second line',
style: new TextStyle(fontWeight: FontWeight.bold)),
new TextSpan(
text: ' background on me ',
style: new TextStyle(
fontWeight: FontWeight.bold,
background: Paint()..color = Colors.redAccent,
)),
new TextSpan(text: ' This is another of the lines in the span!'),
],
),
), // This trailing comma makes auto-formatting nicer for build methods.
)
我try 将height
添加到文本样式,但它不影响背景高度.