gpt4 book ai didi

flutter 富文本分隔对齐

转载 作者:IT王子 更新时间:2023-10-29 07:05:48 25 4
gpt4 key购买 nike

我在 flutter 中看到了富文本代码:

  return Row(
children: <Widget>[
?
Container(
child: RichText(
text: TextSpan(
text: "Hello",
style: TextStyle(fontSize: 20.0,color: Colors.black),
children: <TextSpan>[
TextSpan(text:"Bold"),
style: TextStyle( fontSize: 10.0, color: Colors.grey),

),

],
),
),
)

这幅画

Hellobold 

但我需要像这样将两个文本从左到右分开

Hello                               bold

我该怎么做?

谢谢

最佳答案

我不知道您的确切用例 - 但获得所需内容的一种方法:

Row(
children: <Widget>[
Expanded(
child: RichText(
text: TextSpan(children: [
TextSpan(text: 'Singh', style: TextStyle(fontSize: 22.0,color: Colors.grey))
])),
),
RichText(
text: TextSpan(children: [
TextSpan(text: 'Kaur', style: TextStyle(fontSize: 28.0,color: Colors.redAccent))
])),
],
),

关于flutter 富文本分隔对齐,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53133778/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com