flutter - Flutter:如何增加文本中标签“\ t”的缩进宽度
问题描述
我有以下用于打印文本的小部件:
class NormalText extends StatelessWidget {
final String txt;
NormalText(this.txt) {}
@override
Widget build(BuildContext context) {
return Container(
child: Text(txt,
style: TextStyle(
color: Colors.grey,
fontSize: 20,
fontWeight: FontWeight.bold)));
}
}
但如果我像这样使用它:
NormalText('hello\tworld\t42')
\t 缩进太小。有没有办法增加缩进以占用更多空间?
解决方案
如果您仍然想保留单词之间的空格,并且只增加选项卡,您可以使用 Wrap 小部件
Wrap(
children: "hello hello\tworld\t42"
.split("\t")
.map((text) => Text(text))
.expand((element) => [
element,
SizedBox(
width: 50,
)
])
.toList()
..removeLast(),
),
推荐阅读
- kubernetes - 获取 keyvaultClient 失败:获取密钥保管库令牌失败
- python - 为所有对角线创建一个 NxN 数组
- java - 较新的 PDFBox 版本加载 PDF 缓慢
- php - 如何使用具有相同键但多个值的http post将数据发送到php文件api?
- php - 在一行中显示与相同ID相关的数据php laravel
- html - CSS背景图像不显示
- scala - HDFS 文件拆分命令:使用 spark-submit 的 Spark/Scala
- javascript - 使用javascript将html表格转换为csv时如何合并或组合单元格
- c# - 如何防止使用 ListBox 中的箭头在项目之间切换?
- javascript - 使反应组件可点击