如何修复文本小部件填充?

时间:2019-08-10 18:30:58

标签: flutter dart

随着字体大小的增加,在小部件内部上下添加缩进,因此元素处于不同级别。如何删除该缩进?屏幕上的链接

Widget build(BuildContext context) {
    return Container(
       child: Row(
         mainAxisAlignment: MainAxisAlignment.spaceBetween,
         crossAxisAlignment: CrossAxisAlignment.end,
         children: <Widget>[
            Text("24°"),
            Text("40°", style: TextStyle(fontSize: 80.0,), textAlign: TextAlign.end),
            Text("42°")
         ],
       ),
    );
  }

Widget screen

1 个答案:

答案 0 :(得分:1)

此解决方案减少了怪异移位问题。

Container(
        child: Row(
          mainAxisAlignment: MainAxisAlignment.spaceBetween,
          crossAxisAlignment: CrossAxisAlignment.baseline,
          textBaseline: TextBaseline.alphabetic,
          children: <Widget>[
            Text(
              "24°",
              style: TextStyle(fontSize: 40.0),
            ),
            Text(
              "40°",
              style: TextStyle(fontSize: 100.0),
            ),
            Text(
              "42°",
              style: TextStyle(fontSize: 40.0),
            )
          ],
        ),
      )

output

编辑

showing the baseline